Seq[A: A]
A sequence of elements.
interface ref Seq[A: A]
Constructors
create
Create a sequence, reserving space for len elements.
new ref create( len: USize val = 0) : Seq[A] ref^
Parameters
- len: USize val = 0
Returns
- Seq[A] ref^
Public Functions
reserve
Reserve space for len elements.
fun ref reserve( len: USize val) : None val
Parameters
- len: USize val
Returns
- None val
size
Returns the number of elements in the sequence.
fun box size() : USize val
Returns
- USize val
apply
Returns the i-th element of the sequence. Raises an error if the index is out of bounds.
fun box apply( i: USize val) : this->A ?
Parameters
- i: USize val
Returns
- this->A ?
update
Replaces the i-th element of the sequence. Returns the previous value. Raises an error if the index is out of bounds.
fun ref update( i: USize val, value: A) : A^ ?
Parameters
- i: USize val
- value: A
Returns
- A^ ?
clear
Removes all elements from the sequence.
fun ref clear() : None val
Returns
- None val
push
Adds an element to the end of the sequence.
fun ref push( value: A) : None val
Parameters
- value: A
Returns
- None val
pop
Removes an element from the end of the sequence.
fun ref pop() : A^ ?
Returns
- A^ ?
unshift
Adds an element to the beginning of the sequence.
fun ref unshift( value: A) : None val
Parameters
- value: A
Returns
- None val
shift
Removes an element from the beginning of the sequence.
fun ref shift() : A^ ?
Returns
- A^ ?
append
Add len elements to the end of the list, starting from the given offset.
fun ref append( seq: (ReadSeq[A] box & ReadElement[A^] box), offset: USize val = 0, len: USize val = call) : None val
Parameters
- seq: (ReadSeq[A] box & ReadElement[A^] box)
- offset: USize val = 0
- len: USize val = call
Returns
- None val
concat
Add len iterated elements to the end of the list, starting from the given offset.
fun ref concat( iter: Iterator[A^] ref, offset: USize val = 0, len: USize val = call) : None val
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.
fun ref truncate( len: USize val) : None val
Parameters
- len: USize val
Returns
- None val
values
Returns an iterator over the elements of the sequence.
fun box values() : Iterator[this->A] ref^
Returns
- Iterator[this->A] ref^
© 2016-2020, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/builtin-Seq