List of comparable generics
OperationsCode example:
function : Example() ~ Nil {
# insert elements
list := Collection.CompareList->New()<FloatRef>;
list->AddBack(33.3);
list->AddFront(66.6);
list->AddBack(99.9);
# get size
list->Size()->PrintLine();
# find value
list->Has(66.6)->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();
};
}
Default constructor
New()
Adds a value to the end
method : public : native : AddBack(value:H) ~ Nil
Name | Type | Description |
---|---|---|
value | H | value to append |
Adds a value to the front
method : public : native : AddFront(value:H) ~ Nil
Name | Type | Description |
---|---|---|
value | H | value to prepend |
Returns the last element in the list
method : public : Back() ~ H
Type | Description |
---|---|
H | last element in the list, Nil if the list is empty |
Instance of a backward iterator
method : public : BackwardIterator() ~ CompareBackwardIterator<H>
Type | Description |
---|---|
CompareBackwardIterator<H> | Backward iterator |
Clears the list
method : public : Empty() ~ Nil
Uses the given function to filter out values
method : public : Filter(f:(H)~Bool) ~ CompareList<H>
Name | Type | Description |
---|---|---|
f | (H)~Bool | function to use a filter. If the function evaluates to true the value is added to the collection. |
Type | Description |
---|---|
CompareList<H> | filtered list |
Finds a value in the list and sets the pointer
method : public : Find(value:H) ~ H
Name | Type | Description |
---|---|---|
value | H | value to search for |
Type | Description |
---|---|
H | value that's found |
Moves the pointer to the end of the list
method : public : Forward() ~ Nil
Instance of a forward iterator
method : public : ForwardIterator() ~ CompareForwardIterator<H>
Type | Description |
---|---|
CompareForwardIterator<H> | forward iterator |
Returns the first element in the list
method : public : Front() ~ H
Type | Description |
---|---|
H | first element in the list, Nil if the list is empty |
Gets the value that's currently pointed to
method : public : Get() ~ H
Type | Description |
---|---|
H | value value |
Searches for a value
method : public : Has(value:H) ~ Bool
Name | Type | Description |
---|---|---|
value | H | value to check for |
Type | Description |
---|---|
Bool | true if value is found, false otherwise |
Inserts a value into the list based upon the pointer location
method : public : native : Insert(value:H) ~ Bool
Name | Type | Description |
---|---|---|
value | H | value to insert |
Checks to see if the pointer is at the end of the list
method : public : IsBack() ~ Bool
Type | Description |
---|---|
Bool | true if pointer is at the end of the list, false otherwise |
Checks to see if the list is empty
method : public : IsEmpty() ~ Bool
Type | Description |
---|---|
Bool | true if empty, false otherwise |
Checks to see if the pointer is at the front of the list
method : public : IsFront() ~ Bool
Type | Description |
---|---|
Bool | true if pointer is at the front of the list, false otherwise |
Maps the given function to each value in the list
method : public : Map(f:(H)~H) ~ CompareList<H>
Name | Type | Description |
---|---|---|
f | (H)~H | function to apply |
Type | Description |
---|---|
CompareList<H> | newly calculated list |
Checks to see the pointer can be advanced
method : public : More() ~ Bool
Type | Description |
---|---|
Bool | true if pointer can be advanced, false otherwise |
Advances the pointer
method : public : Next() ~ Nil
Retreats the pointer
method : public : Previous() ~ Nil
Removes the element at the pointer position
method : public : native : Remove() ~ Nil
Removes the element at the pointer position
method : public : native : Remove(node:CompareListNode<H>) ~ Nil
Name | Type | Description |
---|---|---|
node | CompareListNode<H> | node |
Removes the last value from the list
method : public : RemoveBack() ~ Nil
Removes the first value from the list
method : public : RemoveFront() ~ Nil
List of all but first element
method : public : Rest() ~ CompareList<H>
Type | Description |
---|---|
CompareList<H> | all but first element |
Moves the pointer to the start of the list
method : public : Rewind() ~ Nil
Size of list
method : public : Size() ~ Int
Type | Description |
---|---|
Int | size of list |
Converts the list into an object array
method : public : ToArray() ~ H[]
Type | Description |
---|---|
H | object array |
Formats the collection into a string. If an element implements the 'Stringify' interface, it's 'ToString()' is called.
method : public : ToString() ~ String
Type | Description |
---|---|
String | string representation |