jam.types.base.sequences.array module
- class jam.types.base.sequences.array.Array(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]
Bases:
BaseSequence,Generic[T]Fixed-length array is an extension of the BaseSequence, to only allow fixed length arrays.
The array has a fixed length, append, extend, pop, insert, remove, and clear methods are not supported. Elements can be: - Set/Updated at any index - Swapped with another element at any index - Get from any index
- __init__(initial: Sequence[T] = [], codec: Codec[T] | None = None)[source]
Initialize array.
- Parameters:
initial – Required initial values
- Raises:
TypeError – If elements are not all of the same Codable type
ValueError – If initial values don’t match fixed length
- append(value: T) None[source]
Append value to end of vector.
- Parameters:
value – Value to append. Must be instance of the same type as other elements.
- Raises:
TypeError – If value is not of the correct type
- pop(index: int = -1) T[source]
Remove and return item at index.
- Parameters:
index – Index of item to remove
- Returns:
Removed item
- Raises:
IndexError – If index out of range
- insert(index: int, value: T) None[source]
Insert value at index.
- Parameters:
index – Index to insert at
value – Value to insert. Must be instance of the same type as other elements.
- Raises:
TypeError – If value is not of the correct type
- remove(value: T) None[source]
Remove first occurrence of value.
- Parameters:
value – Value to remove
- Raises:
ValueError – If value not found
- jam.types.base.sequences.array.decodable_array(length: int, element_type: Type[T]) Callable[[Type[Any]], Type[Any]][source]
Decorator that creates a fixed-length array type with a specific element type.
This decorator configures the array class with: 1. Fixed length 2. Element type validation 3. Custom decode_from implementation