All Bundles

CompareList<H:Compare>

List of comparable generics

Operations

Code 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();
   };
}

New

Default constructor

New()

AddBack

Adds a value to the end

method : public : native : AddBack(value:H) ~ Nil
Parameters
NameTypeDescription
valueHvalue to append

AddFront

Adds a value to the front

method : public : native : AddFront(value:H) ~ Nil
Parameters
NameTypeDescription
valueHvalue to prepend

Back

Returns the last element in the list

method : public : Back() ~ H
Return
TypeDescription
Hlast element in the list, Nil if the list is empty

BackwardIterator

Instance of a backward iterator

method : public : BackwardIterator() ~ CompareBackwardIterator<H>
Return
TypeDescription
CompareBackwardIterator<H>Backward iterator

Empty

Clears the list

method : public : Empty() ~ Nil

Filter

Uses the given function to filter out values

method : public : Filter(f:(H)~Bool) ~ CompareList<H>
Parameters
NameTypeDescription
f(H)~Boolfunction to use a filter. If the function evaluates to true the value is added to the collection.

Return
TypeDescription
CompareList<H>filtered list

Find

Finds a value in the list and sets the pointer

method : public : Find(value:H) ~ H
Parameters
NameTypeDescription
valueHvalue to search for

Return
TypeDescription
Hvalue that's found

Forward

Moves the pointer to the end of the list

method : public : Forward() ~ Nil

ForwardIterator

Instance of a forward iterator

method : public : ForwardIterator() ~ CompareForwardIterator<H>
Return
TypeDescription
CompareForwardIterator<H>forward iterator

Front

Returns the first element in the list

method : public : Front() ~ H
Return
TypeDescription
Hfirst element in the list, Nil if the list is empty

Get

Gets the value that's currently pointed to

method : public : Get() ~ H
Return
TypeDescription
Hvalue value

Has

Searches for a value

method : public : Has(value:H) ~ Bool
Parameters
NameTypeDescription
valueHvalue to check for

Return
TypeDescription
Booltrue if value is found, false otherwise

Insert

Inserts a value into the list based upon the pointer location

method : public : native : Insert(value:H) ~ Bool
Parameters
NameTypeDescription
valueHvalue to insert

IsBack

Checks to see if the pointer is at the end of the list

method : public : IsBack() ~ Bool
Return
TypeDescription
Booltrue 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
TypeDescription
Booltrue if empty, false otherwise

IsFront

Checks to see if the pointer is at the front of the list

method : public : IsFront() ~ Bool
Return
TypeDescription
Booltrue if pointer is at the front of the list, false otherwise

Map

Maps the given function to each value in the list

method : public : Map(f:(H)~H) ~ CompareList<H>
Parameters
NameTypeDescription
f(H)~Hfunction to apply

Return
TypeDescription
CompareList<H>newly calculated list

More

Checks to see the pointer can be advanced

method : public : More() ~ Bool
Return
TypeDescription
Booltrue if pointer can be advanced, false otherwise

Next

Advances the pointer

method : public : Next() ~ Nil

Previous

Retreats the pointer

method : public : Previous() ~ Nil

Remove

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
Parameters
NameTypeDescription
nodeCompareListNode<H>node

RemoveBack

Removes the last value from the list

method : public : RemoveBack() ~ Nil

RemoveFront

Removes the first value from the list

method : public : RemoveFront() ~ Nil

Rest

List of all but first element

method : public : Rest() ~ CompareList<H>
Return
TypeDescription
CompareList<H>all but first element

Rewind

Moves the pointer to the start of the list

method : public : Rewind() ~ Nil

Size

Size of list

method : public : Size() ~ Int
Return
TypeDescription
Intsize of list

ToArray

Converts the list into an object array

method : public : ToArray() ~ H[]
Return
TypeDescription
Hobject 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
TypeDescription
Stringstring representation