ViewableSequence

class zixy.container.base.ViewableSequence[source]

Bases: ViewableBase[ImplT, slice], Generic[T, ImplT], Sequence[T]

Abstract base class for sequences with an ownership model and underlying Rust-bound data.

__getitem__(indexer: int | slice) T | Self[source]
Overloads:
  • self, indexer (int) → T

  • self, indexer (builtins.slice) → Self

Get the element or elements selected by indexer.

Parameters:

indexer – Index or slice selecting the element(s) to return.

Returns:

Element or slice selected by indexer.

__iter__() Iterator[T][source]

Iterate over the elements of self.

__len__() int[source]

Get the number of elements in self.

as_view() Self[source]

Return a view of self.

Returns:

If self is owning, a new view on the same underlying data, otherwise self.

abstractmethod clone() Self

Return a deep copy of self.

count(value) integer -- return number of occurrences of value
classmethod from_size(n: int) Self[source]

Create a new instance of cls with the given size.

Parameters:

n – The size of the new instance.

Returns:

An instance of cls with the given size.

classmethod from_view(source: Self) Self[source]

Create a new instance of cls from a view.

Parameters:

source – View to clone into the new instance.

Returns:

An owning clone of source.

into(t: type[OutT]) OutT

Clone self into a new related container of type t.

Parameters:

t – Type of the new container to create.

Returns:

A new instance of t containing the same data as self.

is_owning() bool[source]

Check if self is owning (i.e. not a view).

map_index(i: int) int[source]

Map an index in self to an index in the underlying data.

Parameters:

i – Index in self.

Returns:

Corresponding index in the underlying data.

resize(n: int) Self[source]

Resize the underlying container.

Parameters:

n – The new size of the container.

Note

This method operates in-place.

Raises:

ValueError – If the container is a view.