ValueVector

class dsviper.ValueVector

Bases: Value

A value of type vector<element_type>. Seamless with a Python seq[object].

Or use Value.create(type_vector [, initial_value]).

This constructor builds a new container over the same elements, so only a mutation inside an element shows through - unless the vector is pack sized, see is_pack_sized.

append(value: _InputValues) → None

Append value to the end of the vector.

at(index: int, *, encoded: Literal[True] = True) → _OutputValues

Return the value at index.

encoded=False returns a Value rather than a native object.

index runs from 0 to len - 1; anything else is out of range, a negative one included. value[-1] follows Python’s own indexing.

back(*, encoded: Literal[True] = True) → _OutputValues

Return the back element or raise.

encoded=False returns a Value rather than a native object.

capacity() → int

Return how many elements the vector can hold before it grows.

static cast(value: Value | _OutputValues) → ValueVector

Return value as a vector<element_type>, or raise if it is not one.

clear() → None

Remove all items.

contains(value: _InputValues) → bool

Return True if the value is present.

copy() → ValueVector

Return a deep copy.

count(value: _InputValues) → int

Return the number of occurrences for the value.

description(*, namespace: NameSpace | None = None) → str

Return the value written out, then its type, as <value>:<type>.

namespace qualifies the type name; representation() gives the value alone.

empty() → bool

Return True if the container is empty.

exchange(idx1: int, idx2: int) → None

Exchange the value at idx1 with the value at idx2.

extend(values: Sequence | ValueVector) → None

Extend the vector by appending the values.

front(*, encoded: Literal[True] = True) → _OutputValues

Return the front element or raise.

encoded=False returns a Value rather than a native object.

hash() → int

Return the hash value.

index(value: _InputValues) → int

Return the first index of value.

insert(index: int, value: _InputValues) → None

Insert value before index.

is_pack_sized() → bool

Return True if the vector keeps its elements packed and encoded.

They sit in one contiguous array of binary encoded elements. A pack-sized vector has value semantics: at() decodes a fresh copy on each call, so a mutation of that copy reaches the vector only through set(index, value). An element type that is not sized (Type.is_sized) is kept unpacked.

pop(index: int = -1, *, encoded: Literal[True] = True) → _OutputValues

Remove and return the element at index, the last one by default.

Raise if the vector is empty or index is out of range.

encoded=False returns a Value rather than a native object.

remove(value: _InputValues) → None

Remove first occurrence of value. Raises error if the value is not present.

representation() → str

Return the value written out: the elements between square brackets, comma separated.

reserve(size: int) → None

Reserve space for size.

resize(size: int) → None

Grow or shrink the vector to size.

New elements hold the element type’s default; elements beyond size are dropped.

set(index: int, value: _InputValues) → None

Set the value at index.

shrink_to_fit() → None

Release the capacity beyond size(), so capacity() becomes size().

size() → int

Return the number of elements.

type() → Type

Return the Type this value is an instance of.

type_code() → str

Return the code naming this kind of value, such as “int32”, “struct” or “vector”.

type_vector() → TypeVector

Return the type vector<element_type>.