ResizableSeq[A: A]¶
A resizable sequence of elements.
The create constructor and reserve method accept capacity hints.
Implementations that don't use a pre-allocated buffer may ignore them.
Constructors¶
create¶
Create a sequence. The len parameter is a capacity hint for initial
capacity; implementations may ignore it.
Parameters¶
- len: USize val = 0
Returns¶
- ResizableSeq[A] ref^
Public Functions¶
size¶
Returns the number of elements in the sequence.
Returns¶
- USize val
apply¶
Returns the i-th element of the sequence. Raises an error if the index is out of bounds.
Parameters¶
- i: USize val
Returns¶
- this->A ?
update¶
Replaces the i-th element of the sequence, returning the previous value. Raises an error if the index is out of bounds.
Parameters¶
- i: USize val
- value: A
Returns¶
- A^ ?
values¶
Returns an iterator over the elements of the sequence.
Returns¶
- Iterator[this->A] ref^
reserve¶
Reserve space for len elements. Implementations that don't use a pre-allocated buffer may ignore this.
Parameters¶
- len: USize val
Returns¶
- None val
clear¶
Removes all elements from the sequence.
Returns¶
- None val
push¶
Adds an element to the end of the sequence.
Parameters¶
- value: A
Returns¶
- None val
pop¶
Removes an element from the end of the sequence.
Returns¶
- A^ ?
unshift¶
Adds an element to the beginning of the sequence.
Parameters¶
- value: A
Returns¶
- None val
shift¶
Removes an element from the beginning of the sequence.
Returns¶
- A^ ?
append¶
Add len elements to the end of the sequence, starting from the given offset.
fun ref append(
seq: (ReadSeq[A] box & ReadElement[A^] box),
offset: USize val = 0,
len: USize val = -1)
: None val
Parameters¶
- seq: (ReadSeq[A] box & ReadElement[A^] box)
- offset: USize val = 0
- len: USize val = -1
Returns¶
- None val
concat¶
Add len iterated elements to the end of the sequence, starting from the given offset.
Parameters¶
Returns¶
- None val
truncate¶
Truncate the sequence to the given length, discarding excess elements. If the sequence is already smaller than len, do nothing.
Parameters¶
- len: USize val
Returns¶
- None val