Skip to main content

CompactArray

This class provides a wrapper on top of BitSet to store items of arbitrary size (up to 64 bits each) efficiently.

Attributes

AttributeTypeDescription
ItemSizeuintThe size of each item in bits, used to determine how many bits are allocated for each element in the CompactArray.
ItemsCountuintThe 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

NameTypeDescription
indexintThe 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

NameTypeDescription
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

NameTypeDescription
indexintThe 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

NameTypeDescription
indexintThe integer index from which to retrieve the item.

Returns

TypeDescription
[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

TypeDescription
[][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

TypeDescription
stringA 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

NameTypeDescription
out*CompactArrayA 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

TypeDescription
*CompactArrayA new CompactArray instance containing a deep copy of the original array's data.