14 #ifndef DOUBLE_LINKED_LIST_IMPL_CPP
15 #define DOUBLE_LINKED_LIST_IMPL_CPP
26 namespace DoubleLinkedListImpl {
43 : thePrevious(previous), theNext(next)
59 thePrevious = previous;
91 if(other == theNext) {
94 }
else if(other == thePrevious) {
96 other->swapWithNext();
99 swapWithDisjoint(other);
112 if(
this == other || theNext == other) {
116 this->getPrevious()->setNext(this->getNext());
117 this->getNext()->setPrevious(this->getPrevious());
121 this->setNext(other);
134 this->thePrevious->theNext = other;
137 other->theNext->thePrevious =
this;
140 other->thePrevious = this->thePrevious;
143 this->thePrevious = other;
146 this->theNext = other->theNext;
149 other->theNext =
this;
158 void Node<T>::swapWithDisjoint(Node<T>* other) {
165 this->thePrevious->theNext = other;
168 this->theNext->thePrevious = other;
171 other->thePrevious->theNext =
this;
174 other->theNext->thePrevious =
this;
177 std::swap(this->thePrevious, other->thePrevious);
180 std::swap(this->theNext, other->theNext);
198 :
Node<T>(previous, next), theT(t)
virtual ~DataNode()
Destructor for DataNode.
DataNode(const value_type &t, Node< T > *previous=NULL, Node< T > *next=NULL)
Create a DataNode with the given value t, previous and next pointers.
DoubleLinkedList internal Node base class.
void moveBefore(Node *other)
Move this node before other by appropriately updating previous and next pointers.
void setPrevious(Node *previous)
Set the Node sequentially before this Node, or NULL for none.
void setNext(Node *next)
Set the Node sequentially after this Node, or NULL for none.
Node(Node *previous=NULL, Node *next=NULL)
Create a Node with the given previous and next pointers.
void swapWith(Node *other)
Swap this node with other by appropriately updating previous and next pointers.
Node * getPrevious() const
This file is to be included at the end of Iterator.h.
void swap(Iterator< T, List, Node > &a, Iterator< T, List, Node > &b)
Swap the values at a and b.