#include <linkedlist.h>
Collaboration diagram for LinkedList< T >:
Public Member Functions | |
LinkedList () | |
Construct empty list:. | |
~LinkedList () | |
T * | first () const |
Get first and last element of the list (or NULL). | |
T * | last () const |
bool | IsEmpty () const |
Returns true if the list is empty otherwise false. | |
T * | next (T *p) const |
T * | prev (T *p) const |
const T * | next (const T *p) const |
const T * | prev (const T *p) const |
void | AssignList (const LinkedList< T > *l) |
void | SwapList (LinkedList< T > *l) |
This is similar, just that the list pointers are swapped. | |
void | insert (T *p) |
Insert p at the beginning of the list:. | |
void | append (T *p) |
Append p to the end of the list:. | |
T * | replace (T *newp, T *oldp) |
void | QueueBefore (T *p, T *where) |
void | QueueAfter (T *p, T *where) |
void | queue (T *p, T *where, int loc) |
T * | dequeue (T *p) |
Dequeues element p (and returns p). | |
T * | PopFirst () |
Dequeue first/last element and return it (or NULL):. | |
T * | PopLast () |
const T * | search (const T *p) const |
Find element p in this list; returns either p or NULL. | |
const T * | SearchRev (const T *p) const |
The same as search() but traverse the list from last to first. | |
int | count () const |
Cound the elements in the list:. | |
void | clear () |
Clear list by deleting all entries. | |
void | AppendList (LinkedList< T > &b) |
Append content of passed list to this list. | |
T * | MiddleNode () const |
Find (left) middle element in list. | |
template<typename OP> void | MergeLists (LinkedList< T > &a, LinkedList< T > &b, const OP &_OP) |
Merge two sorted lists. | |
template<typename OP> void | MergeSort (const OP &_OP) |
Sort the list. | |
Private Member Functions | |
LinkedList & | operator= (const LinkedList &l) |
Don't use: (use AssignList in rare cases):. | |
LinkedList (const LinkedList &l) | |
Private Attributes | |
T * | lfirst |
T * | llast |
Definition at line 126 of file linkedlist.h.
|
Definition at line 134 of file linkedlist.h. |
|
Construct empty list:.
Definition at line 138 of file linkedlist.h. |
|
It is your responsibility to properly empty the list before destroying it. Definition at line 141 of file linkedlist.h. |
|
Append p to the end of the list:.
Definition at line 182 of file linkedlist.h. Referenced by LinkedList< FileNode >::MergeLists(), and LinkedList< FileNode >::QueueAfter(). |
|
Append content of passed list to this list. All elements in the passed list will be appended to this list and the passed list will be empty afterwards. This is much faster than while(!b.IsEmpty()) a.append(b.PopFirst());
Definition at line 310 of file linkedlist.h. Referenced by LinkedList< FileNode >::MergeLists(). |
|
Use with care!! Just copies pointer to head and tail of list; if you modify one of the lists, the other one will get inconsistent if lfirst/llast get modified. Definition at line 161 of file linkedlist.h. |
|
Clear list by deleting all entries.
Definition at line 295 of file linkedlist.h. |
|
Cound the elements in the list:.
Definition at line 287 of file linkedlist.h. |
|
Dequeues element p (and returns p).
Definition at line 238 of file linkedlist.h. |
|
Get first and last element of the list (or NULL).
Definition at line 144 of file linkedlist.h. |
|
Insert p at the beginning of the list:.
Definition at line 170 of file linkedlist.h. Referenced by LinkedList< FileNode >::QueueBefore(). |
|
Returns true if the list is empty otherwise false.
Definition at line 148 of file linkedlist.h. Referenced by LinkedList< FileNode >::AppendList(), LinkedList< FileNode >::clear(), and LinkedList< FileNode >::MergeSort(). |
|
Definition at line 145 of file linkedlist.h. |
|
Merge two sorted lists. The two lists a and b must be ascentingly sorted and will be merged into this list by successively appending the elements from the beginning of a or b to this list. In the end, lists a and b will be empty and all elements will have been appended to this list. Runtime is O(n_a+n_b). This algorithm will use elements of a before those in b in case they are equally large (hence, if list a holds the elements "left" of those in b, it is stable). The passed operator template is used to compare elements; it must implement the le (lesser equal) relation. (Arguments to le are of type "const T &".) Definition at line 368 of file linkedlist.h. Referenced by LinkedList< FileNode >::MergeSort(). |
|
Sort the list. This implements the merge sort algorithm on the list. The runtime is O(n*log(n)) and no additional memory besides the call stack of depth O(log(n)) is required. The sorting algorithm is stable. The passed operator template must implement the le (lesser equal) relation; see MergeLists().
Definition at line 391 of file linkedlist.h. Referenced by LinkedList< FileNode >::MergeSort(). |
|
Find (left) middle element in list. This function finds the middle node element in the list by walking the list from start and end until "colliding" in the middle. Runtime is O(n).
Definition at line 342 of file linkedlist.h. Referenced by LinkedList< FileNode >::MergeSort(). |
|
Definition at line 155 of file linkedlist.h. |
|
Get next/prev element from passed element. May be used if you experience ambiguities using multiple inheritance. Definition at line 153 of file linkedlist.h. |
|
Don't use: (use AssignList in rare cases):.
Definition at line 132 of file linkedlist.h. |
|
Dequeue first/last element and return it (or NULL):.
Definition at line 250 of file linkedlist.h. Referenced by LinkedList< FileNode >::clear(), and LinkedList< FileNode >::MergeLists(). |
|
Definition at line 260 of file linkedlist.h. |
|
Definition at line 156 of file linkedlist.h. |
|
Definition at line 154 of file linkedlist.h. |
|
Queue before/after `whereŽ, depending on loc. loc<0 -> before; loc>0 -> after; loc==0 -> do nothing Definition at line 231 of file linkedlist.h. |
|
Definition at line 218 of file linkedlist.h. Referenced by LinkedList< FileNode >::queue(). |
|
Put p before/after `whereŽ into the queue: Make sure, `whereŽ is not NULL. Definition at line 208 of file linkedlist.h. Referenced by LinkedList< FileNode >::queue(). |
|
Dequeues *oldp and puts newp at the place where oldp was. Make sure neither oldp nor newp are NULL. Returns oldp (so that you may pass it to operator delete). Definition at line 196 of file linkedlist.h. |
|
Find element p in this list; returns either p or NULL.
Definition at line 272 of file linkedlist.h. |
|
The same as search() but traverse the list from last to first.
Definition at line 279 of file linkedlist.h. |
|
This is similar, just that the list pointers are swapped.
Definition at line 165 of file linkedlist.h. |
|
|
Definition at line 129 of file linkedlist.h. Referenced by LinkedList< FileNode >::AppendList(), LinkedList< FileNode >::AssignList(), LinkedList< FileNode >::LinkedList(), LinkedList< FileNode >::MergeSort(), LinkedList< FileNode >::operator=(), and LinkedList< FileNode >::SwapList(). |