Class
CompressedCollection<T>

Sparse collection storing only explicitly set values while appearing to contain values at all indexes, using a default value for unset positions. Enables efficient memory usage for large, mostly-empty grids such as worksheet cell data.

Definition

Namespace:Telerik.Windows.Documents.Spreadsheet.Expressions.DataStructures

Assembly:Telerik.Windows.Documents.Spreadsheet.dll

Type Parameters:

T

The value type stored by the collection.

Syntax:

cs-api-definition
public class CompressedCollection<T> : IEnumerable

Inheritance: objectCompressedCollection<T>

Derived Classes: CompressedExpressionCollection

Implements: IEnumerable

Constructors

CompressedCollection(int, int, T)

Initializes a new instance of the CompressedCollection class with specified dimensions and default value for unset cells.

Declaration

cs-api-definition
public CompressedCollection(int rowCount, int columnCount, T defaultValue)

Parameters

rowCount

int

The number of rows.

columnCount

int

The number of columns.

defaultValue

T

The default value used to initialize all cells of the collection.

Properties

HasValues

Indicates whether any values have been explicitly set in the collection.

Declaration

cs-api-definition
public bool HasValues { get; }

Property Value

bool

Length

The total logical capacity of the collection, representing all positions including unset ones.

Declaration

cs-api-definition
public int Length { get; }

Property Value

int

this[int, int]

Accesses the value at the specified row and column, returning the default value if the cell has not been explicitly set.

Declaration

cs-api-definition
public T this[int rowIndex, int columnIndex] { get; set; }

Parameters

rowIndex

int

The row index of the cell.

columnIndex

int

The column index of the cell.

Property Value

T

Methods

GetEnumerator()

Returns an enumerator that iterates through all logical positions in row-major order, yielding default values for unset cells.

Declaration

cs-api-definition
public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

The enumerator.

GetLength(int)

Returns the size of the specified dimension: 0 for row count, 1 for column count.

Declaration

cs-api-definition
public int GetLength(int dimension)

Parameters

dimension

int

The dimension for which to get the length. 0 for rows, 1 for columns.

Returns

int

The number of items in the selected dimension.