List
Generic list
function : Example() ~ Nil {
# insert elements
list := Collection.List->New()<FloatRef>;
list->AddBack(33.3);
list->AddFront(66.6);
list->AddBack(99.9);
# get size
list->Size()->PrintLine();
# get first and last item
list->Front()->PrintLine();
list->Back()->PrintLine();
# iterate
while(list->More()) {
list->Get()->PrintLine();
list->Next();
};
# iterate backward
backwards := list->BackwardIterator()<FloatRef>;
while(backwards->More()) {
backwards->Get()->PrintLine();
backwards->Next();
};
}
Operations
- New
- AddBack
- AddFront
- Back
- BackwardIterator
- Each
- Empty
- Filter
- Forward
- ForwardIterator
- Front
- Get
- Insert
- IsBack
- IsEmpty
- IsFront
- Limit
- Map
- More
- Next
- Previous
- Reduce
- Remove
- RemoveBack
- RemoveFront
- Rest
- Rewind
- Size
- ToArray
- ToString
AddBack
Adds a value to the end
method : public : native : AddBack(value:H) ~ Nil
Parameters
Name | Type | Description |
---|---|---|
value | H | value to append |
AddFront
Adds a value to the front
method : public : native : AddFront(value:H) ~ Nil
Parameters
Name | Type | Description |
---|---|---|
value | H | value to prepend |
Back
Returns the last element in the list
method : public : Back() ~ H
Return
Type | Description |
---|---|
H | last element in the list, Nil if the list is empty |
BackwardIterator
Instance of a backward iterator
method : public : BackwardIterator() ~ BackwardIterator<H>
Return
Type | Description |
---|---|
BackwardIterator<H> | Backward iterator |
Each
Function called for each element
method : public : Each(f:(H)~Nil) ~ List<H>
Parameters
Name | Type | Description |
---|---|---|
f | (H)~Nil | function called |
Filter
Uses the given function to filter out values
method : public : Filter(f:(H)~Bool) ~ List<H>
Parameters
Name | Type | Description |
---|---|---|
f | (H)~Bool | function to use a filter. If the function evaluates to true the value is added to the collection. |
Return
Type | Description |
---|---|
List<H> | filtered list |
ForwardIterator
Instance of a forward iterator
method : public : ForwardIterator() ~ ForwardIterator<H>
Return
Type | Description |
---|---|
ForwardIterator<H> | forward iterator |
Front
Returns the first element in the list
method : public : Front() ~ H
Return
Type | Description |
---|---|
H | first element in the list, Nil if the list is empty |
Get
Gets the value that's currently pointed to
method : public : Get() ~ H
Return
Type | Description |
---|---|
H | value value |
Insert
Inserts a value into the list based upon the pointer location
method : public : native : Insert(value:H) ~ Bool
Parameters
Name | Type | Description |
---|---|---|
value | H | value to insert |
IsBack
Checks to see if the pointer is at the end of the list
method : public : IsBack() ~ Bool
Return
Type | Description |
---|---|
Bool | true if pointer is at the end of the list, false otherwise |
IsEmpty
Checks to see if the list is empty
method : public : IsEmpty() ~ Bool
Return
Type | Description |
---|---|
Bool | true if empty, false otherwise |
IsFront
Checks to see if the pointer is at the front of the list
method : public : IsFront() ~ Bool
Return
Type | Description |
---|---|
Bool | true if pointer is at the front of the list, false otherwise |
Limit
Returns a limited list
method : public : Limit(l:Int) ~ List<H>
Parameters
Name | Type | Description |
---|---|---|
l | Int | limit |
Return
Type | Description |
---|---|
List<H> | limited list |
Map
Maps the given function to each value in the list
method : public : Map(f:(H)~H) ~ List<H>
Parameters
Name | Type | Description |
---|---|---|
f | (H)~H | function to apply |
Return
Type | Description |
---|---|
List<H> | newly calculated list |
More
Checks to see the pointer can be advanced
method : public : More() ~ Bool
Return
Type | Description |
---|---|
Bool | true if pointer can be advanced, false otherwise |
Reduce
Uses the given function to reduce the values
method : public : Reduce(a:H, f:(H,H)~H) ~ H
Parameters
Name | Type | Description |
---|---|---|
a | H | initial value (i.e. accumulator) |
f | (H,H)~H | function to use a reduce |
Return
Type | Description |
---|---|
H | reduced vector |
Rest
List of all but first element
method : public : Rest() ~ List<H>
Return
Type | Description |
---|---|
List<H> | all but first element |
ToArray
Converts the list into an object array
method : public : ToArray() ~ H[]
Return
Type | Description |
---|---|
H[] | object array |
ToString
Formats the collection into a string. If an element implements the 'Stringify' interface, it's 'ToString()' is called.
method : public : ToString() ~ String
Return
Type | Description |
---|---|
String | string representation |