kspread
KSpread::Cluster Class Reference
#include <kspread_cluster.h>
Detailed Description
Philipp This class defines a pointer map to all cells, which makes access to them more performant and additionally limits memory consumption.In detail: The class defines 2 cluster, where the second cluster (LEVEL2) is a matrix for single cells, while the first cluster (LEVEL1) is a matrix to handle the matrices of LEVEL2. On initialization, one LEVEL1 matrix is generated only. Each time, a cell stores something, this class checks if for the given column and row a matrix of LEVEL2 is already initialized and in case not generates it on the fly. This helps to reduce the memory usage to only consum one pointer matrix for LEVEL1 and all matrices of LEVEL2 that are necessary.
LEVEL1 is defined as 128x128 matrix. LEVEL2 is defined as 256x256 matrices. Each direction then can have LEVEL1 * LEVEL2 = 128*256 = 2^15 different cells, which is in total (2^15)^2 cells.
It can be changed easily to different sizes, but it should be more senseful to have a small LEVEL1, as in most cases only one/two entries in LEVEL1 will be used.
There are 2 additional special classes to store pointers for column and row formats.
Future enhancements: To reduce memory consumption, it should be possible to enhance the functionality by another LEVEL0, which then keeps the LEVEL1 size smaller.
Maybe the LEVEL1 should only be generated when there is a need for more than 1 LEVEL2.
LEVEL1 maybe reallocated.
Another interesting possibility would be to differentiate between x size and y size. Currently both are equal in both matrizes, but normally it will be the regular case, that you have more need for a lot of rows than columns. Maybe something like LEVEL1=128/256 and LEVEL2=256/128 (x/y), still keeping 2^15 values/cells in each direction (benefit: you won't loose memory in empty columns).
Definition at line 72 of file kspread_cluster.h.
Public Member Functions | |
Cluster () | |
~Cluster () | |
Cell * | lookup (int x, int y) const |
void | clear () |
void | insert (Cell *cell, int x, int y) |
void | remove (int x, int y) |
void | setAutoDelete (bool) |
bool | autoDelete () const |
Cell * | firstCell () const |
bool | shiftRow (const QPoint &marker) |
bool | shiftColumn (const QPoint &marker) |
void | unshiftColumn (const QPoint &marker) |
void | unshiftRow (const QPoint &marker) |
bool | insertColumn (int col) |
bool | insertRow (int row) |
void | removeColumn (int col) |
void | removeRow (int row) |
void | clearColumn (int col) |
void | clearRow (int row) |
Value | valueRange (int col1, int row1, int col2, int row2) const |
Cell * | getFirstCellColumn (int col) const |
Cell * | getLastCellColumn (int col) const |
Cell * | getFirstCellRow (int row) const |
Cell * | getLastCellRow (int row) const |
Cell * | getNextCellUp (int col, int row) const |
Cell * | getNextCellDown (int col, int row) const |
Cell * | getNextCellRight (int col, int row) const |
Cell * | getNextCellLeft (int col, int row) const |
Member Function Documentation
void Cluster::clear | ( | ) |
Removes all cells from the sheet and frees memory that was used for the clusters.
Definition at line 78 of file kspread_cluster.cc.
void Cluster::clearColumn | ( | int | col | ) |
Retrieve the first used cell in a given column.
Can be used in conjunction with getNextCellDown to loop through a column.
- Parameters:
-
col The column to get the first cell from
- Returns:
- Returns a pointer to the cell, or NULL if there are no used cells in this column
Definition at line 688 of file kspread_cluster.cc.
Retrieve the first used cell in a given row.
Can be used in conjunction with getNextCellRight to loop through a row.
- Parameters:
-
row The row to get the first cell from
- Returns:
- Returns a pointer to the cell, or NULL if there are no used cells in this row
Definition at line 710 of file kspread_cluster.cc.
Retrieve the last used cell in a given column.
Can be used in conjunction with getNextCellUp to loop through a column.
- Parameters:
-
col The column to get the cell from
- Returns:
- Returns a pointer to the cell, or NULL if there are no used cells in this column
Definition at line 699 of file kspread_cluster.cc.
Retrieve the last used cell in a given row.
Can be used in conjunction with getNextCellLeft to loop through a row.
- Parameters:
-
row The row to get the last cell from
- Returns:
- Returns a pointer to the cell, or NULL if there are no used cells in this row
Definition at line 721 of file kspread_cluster.cc.
Retrieves the next used cell below the given col/row pair.
The given col/row pair does not need to reference a used cell.
- Parameters:
-
col column to start looking through row the row below which to start looking.
- Returns:
- Returns the next used cell below this one, or NULL if there are none
Definition at line 761 of file kspread_cluster.cc.
Retrieves the next used cell to the left of the given col/row pair.
The given col/row pair does not need to reference a used cell.
- Parameters:
-
col the column before which should be searched row the row to search through
- Returns:
- Returns the next used cell to the left of this one, or NULL if there are none
Definition at line 790 of file kspread_cluster.cc.
Retrieves the next used cell to the right of the given col/row pair.
The given col/row pair does not need to reference a used cell.
- Parameters:
-
col the column after which should be searched row the row to search through
- Returns:
- Returns the next used cell to the right of this one, or NULL if there are none
Definition at line 819 of file kspread_cluster.cc.
Retrieves the next used cell above the given col/row pair.
The given col/row pair does not need to reference a used cell.
- Parameters:
-
col column to start looking through row the row above which to start looking.
- Returns:
- Returns the next used cell above this one, or NULL if there are none
Definition at line 732 of file kspread_cluster.cc.
Inserts a cell at the requested position.
If there is already a cell, then remove is called on it.
Definition at line 127 of file kspread_cluster.cc.
bool Cluster::insertColumn | ( | int | col | ) |
Moves all columns beginning with col
one position to the right.
If that does not work because a cell would drop out of the sheet, then false is returned.
- See also:
- removeColumn
Definition at line 370 of file kspread_cluster.cc.
Removes the cell at the given position, if there is any.
Definition at line 169 of file kspread_cluster.cc.
void Cluster::removeColumn | ( | int | col | ) |
Removes all elements from the column and move all columns right of col
one position to the left.
- See also:
- clearColumn
Definition at line 526 of file kspread_cluster.cc.
bool Cluster::shiftColumn | ( | const QPoint & | marker | ) |
Moves all cells in the column marker.x() beginning with the one at marker.y() one position downwards.
- Returns:
- false if a cell would drop out of the sheet because of that. In this case the shift is not performed.
Definition at line 222 of file kspread_cluster.cc.
void Cluster::unshiftColumn | ( | const QPoint & | marker | ) |
Moves all cells in the column marker.x() beginning with the one at marker.y() + 1 one position upwards.
Definition at line 228 of file kspread_cluster.cc.
Retrieve a range of values stored in a Value.
The range is two-leveled with similar structure and reasoning as the storage of cells themselves.
Definition at line 634 of file kspread_cluster.cc.
The documentation for this class was generated from the following files: