Skip to content

ResizableSeq[A: A]

[Source]

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.

interface ref ResizableSeq[A: A]

Constructors

create

[Source]

Create a sequence. The len parameter is a capacity hint for initial capacity; implementations may ignore it.

new ref create(
  len: USize val = 0)
: ResizableSeq[A] ref^

Parameters

Returns


Public Functions

size

[Source]

Returns the number of elements in the sequence.

fun box size()
: USize val

Returns


apply

[Source]

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

Returns

  • this->A ?

update

[Source]

Replaces the i-th element of the sequence, returning the previous value. Raises an error if the index is out of bounds.

fun ref update(
  i: USize val,
  value: A)
: A^ ?

Parameters

Returns

  • A^ ?

values

[Source]

Returns an iterator over the elements of the sequence.

fun box values()
: Iterator[this->A] ref^

Returns


reserve

[Source]

Reserve space for len elements. Implementations that don't use a pre-allocated buffer may ignore this.

fun ref reserve(
  len: USize val)
: None val

Parameters

Returns


clear

[Source]

Removes all elements from the sequence.

fun ref clear()
: None val

Returns


push

[Source]

Adds an element to the end of the sequence.

fun ref push(
  value: A)
: None val

Parameters

  • value: A

Returns


pop

[Source]

Removes an element from the end of the sequence.

fun ref pop()
: A^ ?

Returns

  • A^ ?

unshift

[Source]

Adds an element to the beginning of the sequence.

fun ref unshift(
  value: A)
: None val

Parameters

  • value: A

Returns


shift

[Source]

Removes an element from the beginning of the sequence.

fun ref shift()
: A^ ?

Returns

  • A^ ?

append

[Source]

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

Returns


concat

[Source]

Add len iterated elements to the end of the sequence, starting from the given offset.

fun ref concat(
  iter: Iterator[A^] ref,
  offset: USize val = 0,
  len: USize val = -1)
: None val

Parameters

Returns


truncate

[Source]

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

Returns