14 #ifndef DOUBLE_LINKED_LIST_CPP
15 #define DOUBLE_LINKED_LIST_CPP
37 while(NULL != iterNode) {
51 head.setPrevious(&head);
53 tail.setPrevious(&head);
66 head.setPrevious(&head);
68 tail.setPrevious(&head);
73 push_back(node->operator*());
87 while(curr != &tail) {
89 notifyItersSwapOccurred(tmp, &tail);
96 tail.setPrevious(&head);
102 return head.getNext() == &tail;
111 return iterator(
this, head.getNext());
131 head.getNext()->setPrevious(created);
132 head.setNext(created);
134 notifyItersInsertedBefore(1, created->
getNext());
141 tail.getPrevious()->setNext(created);
142 tail.setPrevious(created);
156 if(NULL != iterHead.getNext()) {
157 iterHead.getNext()->setPrevious(created);
159 iterHead.setNext(created);
171 iterator* atCurr = curr->operator*();
173 curr->getPrevious()->setNext(curr->getNext());
174 if(NULL != curr->getNext()) {
175 curr->getNext()->setPrevious(curr->getPrevious());
198 curr->operator*()->swapOccurred(a, b);
215 for(
Node* node = firstAfter; node != &tail; node=node->
getNext()) {
217 curr->operator*()->insertedBefore(node, count);
235 for(
Node* node = firstAfter; node != &tail; node=node->
getNext()) {
237 curr->operator*()->removedBefore(node, count);
DoubleLinkedList which can be iterated via DoubleLinkedList::iterator.
void clear()
Remove all data from this list.
void push_back(const value_type &value)
Insert value as the last item in this list.
void notifyItersSwapOccurred(Node *a, Node *b) const
Notify all iterators that a swap occurred of nodes a and b so that they can update themselves to keep...
DoubleLinkedList()
Create a new list.
void addIterator(iterator *iter)
Record that iter has been created as an iterator of this list.
void notifyItersInsertedBefore(int count, Node *firstAfter) const
Notify all iterators that count Nodes were inserted before firstAfter.
void removeIterator(iterator *iter)
Record that iter that is being destroyed as an iterator of this list.
void push_front(const value_type &value)
Insert value as the first item in this list and udpate iterators to remain at same position.
void notifyItersRemovedBefore(int count, Node *firstAfter) const
Notify all iterators that count Nodes were removed before firstAfter.
T value_type
Convenience typedef of the type of values in this list.
~DoubleLinkedList()
Destroy a list.
DoubleLinkedList internal Node holding Data.
void setNext(Node *next)
Set the Node sequentially after this Node, or NULL for none.
Iterator class that works genericly on a List containing Node elements with data of type T.
This file is to be included at the end of Iterator.h.