Skip to content

Vector

class Vector<Type> < Object

Resizeable vector with random access.

Member Variables

Name Description
values:Type[_] Elements.
nelements:Integer Number of elements.

Member Functions

Name Description
size Number of elements.
empty Is this empty?
clear Clear all elements.
get Get an element.
set Set an element.
pushFront Insert a new element at the start.
pushBack Insert a new element at the end.
popFront Remove the first element.
popBack Remove the last element.
insert Insert a new element.
erase Erase an element.
shrink Shrink the size.
enlarge Enlarge the size.

Member Fibers

Name Description
walk Iterate over the elements.

Member Function Details

clear

function clear()

Clear all elements.

empty

function empty() -> Boolean

Is this empty?

enlarge

function enlarge(n:Integer, x:Type)

Enlarge the size.

  • n: Number of elements.
  • x: Value for new elements.

The current contents are preserved.

erase

function erase(i:Integer)

Erase an element.

  • i: Position.

get

function get(i:Integer) -> Type

Get an element.

  • i: Position.

insert

function insert(i:Integer, x:Type)

Insert a new element.

  • i: Position.
  • x: Value.

Inserts the new element immediately before the current element at position i. To insert at the end of the container, use a position that is one more than the current size, or pushBack().

popBack

function popBack()

Remove the last element.

popFront

function popFront()

Remove the first element.

pushBack

function pushBack(x:Type)

Insert a new element at the end.

  • x: Value.

pushFront

function pushFront(x:Type)

Insert a new element at the start.

  • x: Value.

set

function set(i:Integer, x:Type)

Set an element.

  • i: Position.
  • x: Value.

shrink

function shrink(n:Integer)

Shrink the size.

  • n: Number of elements.

The current contents are preserved.

size

function size() -> Integer

Number of elements.

Member Fiber Details

walk

fiber walk() -> Type!

Iterate over the elements.

Return: a fiber object that yields each element in forward order.