RaggedArray
final class RaggedArray<Type> < Object
Two-dimensional array where each row has a varying length. Internally, this is stored in one contiguous array for random access.
Member Variables
Name | Description |
---|---|
values:Type[_] | Elements. |
offsets:Integer[_] | Offset into values for each row. |
ncols:Integer[_] | Number of columns in each row. |
nrows:Integer | Number of rows. |
nelements:Integer | Number of elements. |
Member Functions
Name | Description |
---|---|
empty | Is this empty? |
clear | Clear all elements. |
size | Number of rows. |
size | Number of elements for a given row. |
get | Get an element. |
get | Get a row. |
set | Set an element. |
set | Set a row. |
pushBack | Add a new row at the back. |
pushBack | Add a new element to the end of a row. |
shrink | Decrease the number of rows. |
shrink | Decrease the number of columns in a row. |
enlarge | Increase the number of rows. |
enlarge | Increase the number of columns in a row. |
from | First serial index of a row. |
to | Last serial index of a row. |
serial | Serial index of row and column. |
Member Fibers
Name | Description |
---|---|
walk | Iterate over the rows. |
walk | Iterate over the columns of a row. |
Member Function Details
clear
function clear()
Clear all elements.
empty
function empty() -> Boolean
Is this empty?
enlarge
function enlarge(n:Integer)
Increase the number of rows.
- n: Number of rows.
The current contents is preserved.
function enlarge(i:Integer, n:Integer, x:Type)
Increase the number of columns in a row.
- i: Row.
- n: Number of columns.
- x: Value for new elements.
The current contents of the row is preserved.
from
get
pushBack
function pushBack()
Add a new row at the back.
serial
set
function set(i:Integer, x:Type[_])
Set a row.
- i: Row.
- x: Values.
The number of columns in the row must match the number of columns in
x
. Use shrink
or enlarge
beforehand if necessary.
shrink
function shrink(n:Integer)
Decrease the number of rows.
- n: Number of rows.
The current contents is preserved.
function shrink(i:Integer, n:Integer)
Decrease the number of columns in a row.
- i: Row.
- n: Number of columns.
The current contents of the row is preserved.
size
function size() -> Integer
Number of rows.
to
Member Fiber Details
walk
fiber walk() -> Type[_]!
Iterate over the rows.
Return: a fiber object that yields each row in forward order.
fiber walk(i:Integer) -> Type!
Iterate over the columns of a row.
- i: Row.
Return: a fiber object that yields each row in forward order.