Fast growable double linked list.
Class List( ... ) from \ Sequence( ... )
... | An arbitrary list of parameters. |
The list class implements a double linked list of generic Falcon items that has some hooking with the falcon VM. Particularly, instances of the List class can be used as parameters for the Iterator constructor, or an iterator can be generated for them using first() and last() BOM methods. Also, instances of the List class can be used as any other sequence in for/in loops.
For example, the following code:
descr = List("blue", "red", "gray", "purple") for color in descr forfirst >> "Grues are ", color continue end formiddle: >> ", ", color forlast: > " and ", color, "." end
prints:
Grues are blue, red, gray and purple.
Methods | |
len | Returns the number of items stored in the Sequence. |
pop | Removes the last item from the list (and returns it). |
popFront | Removes the first item from the list (and returns it). |
push | Appends given item to the end of the list. |
pushFront | Pushes an item in front of the list. |
Methods inherited from class Sequence | |
append | Adds an item at the end of the sequence. |
back | Returns the last item in the Sequence. |
clear | Removes all the items from the Sequence. |
comp | Appends elements to this sequence through a filter. |
empty | Checks if the Sequence is empty or not. |
first | Returns an iterator to the first element of the Sequence. |
front | Returns the first item in the Sequence. |
last | Returns an iterator to the last element of the Sequence. |
mcomp | Appends elements to this sequence from multiple sources. |
mfcomp | Appends elements to this sequence from multiple sources through a filter. |
prepend | Adds an item in front of the sequence |
Returns the number of items stored in the Sequence.
List.len()
Return | Count of items in the Sequence. |
Removes the last item from the list (and returns it).
List.pop()
Return | The last item in the list. | ||
Raise |
|
Removes the last item from the list (and returns it). If the list is empty, an access exception is raised.
Removes the first item from the list (and returns it).
List.popFront()
Return | The first item in the list. | ||
Raise |
|
Removes the first item from the list (and returns it). If the list is empty, an access exception is raised.
Appends given item to the end of the list.
List.push( item )
item | The item to be pushed. |
Pushes an item in front of the list.
List.pushFront( item )
item | The item to be pushed. |