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 typically checks if the value's size or type conforms to the array's item specifications.

Parameters

NameTypeDescription
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

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

NameTypeDescription
indexintThe integer index from which to retrieve the item.

Returns

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

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

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

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, independent deep copy of the CompactArray. This allows callers to obtain a duplicate of the array's state without affecting the original.

Returns

TypeDescription
*CompactArrayA pointer to a new CompactArray instance that is a deep copy of the original.