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 ensures that the value's size does not exceed the configured item size.
Parameters
| Name | Type | Description |
|---|
| value | [Item](../cache/item.md?sid=flytestdlib_cache_item) | The item value to validate against the array's item size. |
SetItem()
@classmethod
def SetItem(
index: int,
value: [Item](../cache/item.md?sid=flytestdlib_cache_item)
)
Sets the item at the specified index to the given value. This method updates the CompactArray's internal storage with the new item.
Parameters
| Name | Type | Description |
|---|
| index | int | The integer index where the value should be stored. |
| 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 from 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 stored at the given index. |
GetItems()
@classmethod
def GetItems() - > [][Item](../cache/item.md?sid=flytestdlib_cache_item)
Retrieves all items currently stored in the CompactArray as a list. This allows callers to iterate over or process all elements.
Returns
| Type | Description |
|---|
[][Item](../cache/item.md?sid=flytestdlib_cache_item) | A list containing all items from the CompactArray. |
String()
@classmethod
def String() - > string
Generates a string representation of the CompactArray. This is useful for debugging or logging the contents of the array.
Returns
| Type | Description |
|---|
string | A string representation of the CompactArray's contents. |
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 CompactArray instance that is a deep copy of the current array. This method is useful for creating an independent, mutable copy of the array.
Returns
| Type | Description |
|---|
*CompactArray | A new CompactArray instance containing a deep copy of the original array's data. |