Array
final class Array<Type>
Resizeable array with constant-time random access.
- Type Element type. Must be default-constructible.
Slices
Name | Description |
---|---|
[...] | Reference to an element. |
Member Functions
Name | Description |
---|---|
size | Number of elements. |
empty | Is this empty? |
clear | Clear all elements. |
get | Get an element. |
set | Set an element. |
front | Get the first element. |
back | Get the last element. |
pushFront | Insert an element at the front. |
pushFront | Insert a new default-constructed element at the front and return it. |
pushBack | Insert an element at the back. |
pushBack | Insert a new default-constructed element at the back and return it. |
popFront | Remove the first element. |
popBack | Remove the last element. |
insert | Insert a new element. |
erase | Erase an element. |
erase | Erase multiple elements. |
walk | Obtain an iterator. |
Member Slice Details
[i:Integer] -> Type
Reference to an element.
Member Function Details
back
function back() -> Type
Get the last element.
clear
function clear()
Clear all elements.
empty
function empty() -> Boolean
Is this empty?
erase
function erase(i:Integer, n:Integer)
Erase multiple elements.
- i Position.
- n Number of elements.
The size decreases by n
.
front
function front() -> Type
Get the first element.
get
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 back 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 an element at the back.
- x Value.
function pushBack() -> Type
Insert a new default-constructed element at the back and return it.
pushFront
function pushFront(x:Type)
Insert an element at the front.
- x Value.
function pushFront() -> Type
Insert a new default-constructed element at the front and return it.
set
size
function size() -> Integer
Number of elements.
walk
function walk() -> Iterator<Type>
Obtain an iterator.
Returns an iterator across elements in forward order.