This class provides a wrapper on top of BitSet to store items of arbitrary size (up to 64 bits each) efficiently.
Attributes
| Attribute | Type | Description |
|---|
| ItemSize | uint | The size of each item in bits, used to determine how many bits are allocated for each element in the CompactArray. |
| ItemsCount | uint | The total number of items stored in the CompactArray, influencing the overall storage capacity and indexing. |
Methods
validateIndex()
@classmethod
def validateIndex(
index: int
)
Validates if the provided index is within the valid bounds of the CompactArray. This ensures that operations like setting or getting items do not result in out-of-bounds errors.
Parameters
| Name | Type | Description |
|---|
| index | int | The integer index to validate against the array's size. |
validateValue()
@classmethod
def validateValue(
value: [Item](../cache/item.md?sid=flytestdlib_cache_item)
)
Validates if the provided value is suitable for storage in the CompactArray. This typically checks if the value's size or type conforms to the array's item specifications.
Parameters
| Name | Type | Description |
|---|
| value | [Item](../cache/item.md?sid=flytestdlib_cache_item) | The item value to validate before insertion or update. |
SetItem()
@classmethod
def SetItem(
index: int,
value: [Item](../cache/item.md?sid=flytestdlib_cache_item)
)
Sets the item at the specified index with the given value. This method allows for modifying individual elements within the CompactArray.
Parameters
| Name | Type | Description |
|---|
| index | int | The integer index where the value should be placed. |
| value | [Item](../cache/item.md?sid=flytestdlib_cache_item) | The item value to set at the specified index. |
GetItem()
@classmethod
def GetItem(
index: int
) - > [Item](../cache/item.md?sid=flytestdlib_cache_item)
Retrieves the item stored at the specified index. Callers use this to access individual elements of the CompactArray.
Parameters
| Name | Type | Description |
|---|
| index | int | The integer index from which to retrieve the item. |
Returns
| Type | Description |
|---|
[Item](../cache/item.md?sid=flytestdlib_cache_item) | The item value found at the given index. |
GetItems()
@classmethod
def GetItems() - > [][Item](../cache/item.md?sid=flytestdlib_cache_item)
Retrieves all items currently stored within the CompactArray. This method is useful for iterating over or processing all elements.
Returns
| Type | Description |
|---|
[][Item](../cache/item.md?sid=flytestdlib_cache_item) | A list of all items contained in the CompactArray. |
String()
@classmethod
def String() - > string
Generates a string representation of the CompactArray. This is typically used for debugging or logging purposes to get a human-readable output of the array's contents.
Returns
| Type | Description |
|---|
string | A string representation of the CompactArray. |
DeepCopyInto()
@classmethod
def DeepCopyInto(
out: *CompactArray
)
Performs a deep copy of the current CompactArray's contents into another CompactArray instance. This is used to create an independent copy without modifying the original.
Parameters
| Name | Type | Description |
|---|
| out | *CompactArray | A pointer to the destination CompactArray instance where the deep copy will be stored. |
DeepCopy()
@classmethod
def DeepCopy() - > *CompactArray
Creates and returns a new, independent deep copy of the CompactArray. This allows callers to obtain a duplicate of the array's state without affecting the original.
Returns
| Type | Description |
|---|
*CompactArray | A pointer to a new CompactArray instance that is a deep copy of the original. |