A generic template class for a doubly-linked list of pointers-to-T.
A new List isEmpty(), and elements can be added using append(), prepend() or insert(). The list knows its first() and last() elements, and can find() specific ones. You can take() any element away, as well as count() or clear() the entire List.
This class never deletes the List elements themselves. That is the caller's responsibility.
There is also a SortedList template.
Creates an empty list.
Adds d to the end of the List.
Empties the list by simply forgetting about all of its elements.
Returns the number of elements in the list.
Returns an Iterator that points beyond the last element in the List. In a boolean context, this Iterator evaluates to false.
Returns an Iterator pointing to the position of the first element in the List that points to an object that is equal to the EString d.
Returns an Iterator pointing to the position of the first element in the List that is equal to d.
Returns an Iterator that points to the first element in the List. The Iterator evaluates to 0 if the list isEmpty().
Inserts d before the element pointed to by i.
Returns true only if the List contains no elements.
Returns an Iterator that points to the last element in the List. The Iterator evaluates to 0 if the list isEmpty().
Adds d to the beginning of the List.
Removes d from the list and returns it as a pointer.
d remains valid and can be dereferenced.
This function is equivalent to take( find( d ) ), in that it finds the position of the first element in the List equal to d, then removes that element. Its advantage is that it performs no memory allocation. It returns a pointer to the removed element, or 0 if it was not found in the List.
Returns a list containing the same items as in this list, sorted as comparator says to. comparator has the same meaning as for qsort(3).
Removes the element pointed to by i from the List, and returns it after incrementing i to point to the next element in the List. If i does not point to a list element (e.g. end()), take() returns 0 and does nothing.
Destroys the list without affecting its contents.
This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.