Index | | | Related pages | | | Classes | | | Functions | | | Entities | | | Function Sets | | | Groups |
class List( ... )
Fast growable double linked list. more...
Constructor | |
init | |
Methods | |
back | Returns the last item in the list. |
clear | Removes all the items from the list. |
empty | Checks if the list is empty or not. |
erase | Removes the item pointed by an iterator from the list. |
first | Returns an iterator to the first element of the list. |
front | Returns the first item in the list. |
insert | Insert an item in a position specified by an iterator. |
last | Returns an iterator to the last element of the list. |
len | Returns the number of items stored in the list. |
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. |
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.
In 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.
List.init( ... ) | |
... | An arbitrary list of parameters. |
This constructor creates a list that may be initially filled with the items passed as parameters. The items are inserted in the order they are passed.
Returns the last item in the list.
List.back( ) | |||
Returns: | The last item in the list. | ||
Raises: |
|
This method overloads the BOM method BOM.back. If the list is not empty, it returns the last element.
Removes all the items from the list.
List.clear( ) |
Checks if the list is empty or not.
List.empty( ) | |
Returns: | True if the list is empty, false if contains some elements. |
Removes the item pointed by an iterator from the list.
List.erase( iter ) | |||
iter | Iterator pointing at the element that must be removed. | ||
Raises: |
|
If the given iterator is a valid iterator to an item of this class, the item is removed and the function returns true; the iterator is also moved forward as if its next() method was called. Other iterators currently active on this list are still valid after this call, except for those pointing to the deleted item which are invalidated.
Returns an iterator to the first element of the list.
List.first( ) | |
Returns: | An iterator. |
Returns an iterator to the first element of the list. If the list is empty, an invalid iterator will be returned, but an insertion on that iterator will succeed and append an item to the list.
Returns the first item in the list.
List.front( ) | |||
Returns: | The first item in the list. | ||
Raises: |
|
This method overloads the BOM method BOM.front. If the list is not empty, it returns the first element.
Insert an item in a position specified by an iterator.
List.insert( it, item ) | |||
it | Iterator pointing where insertion will occur. | ||
item | The item to be inserted. | ||
Raises: |
|
Inserts an item at the position indicated by the iterator. After a successful insert, the new item is placed before the old one and the iterator points to the new item. In example, if inserting at the position indicated by first(), the new item is appended in front of the list and the iterator still points to the first item. To insert at the end of the list, get last() iterator, and move it forward with next(). The iterator is then invalidated, but an insert() will append an item at the end of the list, and the iterator will point to that item. To repeat insertions at the end, call next() after each insert.
If the iterator is invalid (and not pointing to the last-past-one element), an access exception will be rasied.
Returns an iterator to the last element of the list.
List.last( ) | |
Returns: | An iterator. |
Returns an iterator to the last element of the list. If the list is empty, an invalid iterator will be returned, but an insertion on that iterator will succeed and append an item to the list.
Returns the number of items stored in the list.
List.len( ) | |
Returns: | Count of items in the list. |
Removes the last item from the list (and returns it).
List.pop( ) | |||
Returns: | The last item in the list. | ||
Raises: |
|
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( ) | |||
Returns: | The first item in the list. | ||
Raises: |
|
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. |
Index | | | Related pages | | | Classes | | | Functions | | | Entities | | | Function Sets | | | Groups |