|
PLearn 0.1
|
Class description: More...
#include <DoublyLinkedList.h>


Public Member Functions | |
| DoublyLinkedList () | |
| DoublyLinkedListElement< T > * | pushOnTop (T entry) |
| void | moveToFront (DoublyLinkedListElement< T > *element) |
| void | removeLast () |
| int | nElements () |
| virtual | ~DoublyLinkedList () |
Public Attributes | |
| DoublyLinkedListElement< T > * | first |
| DoublyLinkedListElement< T > * | last |
| int | n_elements |
Class description:
Doubly linked list of with a 'move-to-front' operation, done in constant time.
Definition at line 79 of file DoublyLinkedList.h.
| PLearn::DoublyLinkedList< T >::DoublyLinkedList | ( | ) | [inline] |
Definition at line 85 of file DoublyLinkedList.h.
: first(0), last(0), n_elements(0) {}
| virtual PLearn::DoublyLinkedList< T >::~DoublyLinkedList | ( | ) | [inline, virtual] |
| void PLearn::DoublyLinkedList< T >::moveToFront | ( | DoublyLinkedListElement< T > * | element | ) | [inline] |
Definition at line 100 of file DoublyLinkedList.h.
{
#ifdef BOUNDCHECK
if (dbg)
cout << "calling DoublyLinkedList::moveToFront(" << element << endl;
if (!element) PLERROR("DoublyLinkedList::moveToFront called with NULL element\n");
#endif
if (element!=first)
{
DoublyLinkedListElement<T>* next = element->next;
DoublyLinkedListElement<T>* previous = element->previous;
// there must be a previous o/w element would have been first
#ifdef BOUNDCHECK
if (!previous)
PLERROR("DoublyLinkedList::moveToFront called on incorrect element or corrupted list\n");
if (previous->next != element)
PLERROR("DoublyLinkedList::moveToFront called on element not part of list (previous->next != element)\n");
if (next && next->previous != element)
PLERROR("DoublyLinkedList::moveToFront called on element not part of list (next->previous != element)\n");
#endif
element->next = first;
element->previous = 0;
previous->next = next;
if (next)
next->previous = previous;
first->previous = element;
first = element;
if (element==last)
last = previous;
}
}
| int PLearn::DoublyLinkedList< T >::nElements | ( | ) | [inline] |
Definition at line 149 of file DoublyLinkedList.h.
{ return n_elements; }
| DoublyLinkedListElement<T>* PLearn::DoublyLinkedList< T >::pushOnTop | ( | T | entry | ) | [inline] |
Definition at line 87 of file DoublyLinkedList.h.
| void PLearn::DoublyLinkedList< T >::removeLast | ( | ) | [inline] |
Definition at line 133 of file DoublyLinkedList.h.
| DoublyLinkedListElement<T>* PLearn::DoublyLinkedList< T >::first |
Definition at line 81 of file DoublyLinkedList.h.
| DoublyLinkedListElement<T>* PLearn::DoublyLinkedList< T >::last |
Definition at line 82 of file DoublyLinkedList.h.
| int PLearn::DoublyLinkedList< T >::n_elements |
Definition at line 83 of file DoublyLinkedList.h.
1.7.4