ADTList
Double linked list class. Fast for insertions and remove and head or tail.
If life time handling of allocated elements is needed the callback procedures duplicate and dispose can be used.
By default the list only takes references of elements and the caller is responsible for keeping elements alive.
Procedures
List.Init
Initialize
PROCEDURE (VAR this : List) Init*;
List.Dispose
Removes all elements from the list.
PROCEDURE (VAR this: List) Dispose*;
List.Size
Returns the size of the list.
PROCEDURE (VAR this-: List) Size* (): LENGTH;
List.IsEmpty
Returns whether the list is empty.
PROCEDURE (VAR this-: List) IsEmpty* (): BOOLEAN;
List.Apply
Apply procedure to all elements of the list.
PROCEDURE (VAR this: List) Apply* (proc : PROC);
List.Append
Append element to tail of list
PROCEDURE (VAR this: List) Append* (element-: Element);
List.AppendHead
Append element to head of list
PROCEDURE (VAR this: List) AppendHead* (element-: Element);
List.Pop
Remove and return element at tail of list- Return FALSE if list is empty. Note this may be duplicate the element and the caller would be responsible for the lifetime of the element.
PROCEDURE (VAR this: List) Pop* (VAR element: Element): BOOLEAN;
List.PopHead
Remove and return element at head of list Return FALSE if list is empty. Note this may be duplicate the element and the caller would be responsible for the lifetime of the element.
PROCEDURE (VAR this: List) PopHead* (VAR element: Element): BOOLEAN;
List.First
Returns an forward iterator for the list.
PROCEDURE (VAR this-: List) First* (VAR iterator: Iterator);
List.Last
Returns an reverse iterator for the list.
PROCEDURE (VAR this-: List) Last* (VAR iterator: Iterator);
Iterator.Next
Advance iterator. Return FALSE if end is reached. Note this may be duplicate the element and the caller would be responsible for the lifetime of the element.
PROCEDURE (VAR this: Iterator) Next* (VAR element: Element): BOOLEAN;