40 typename TElementBase,
60 typename TPointerBase,
61 DoublyLinkedListPointers<T>(TPointerBase::*Pointers)>
70 if (nodePointers.pPrevious) {
72 nodePointers.pPrevious->*Pointers;
73 previousPointers.pNext = nodePointers.pNext;
75 }
else if (this->_pHead == &node) {
76 this->_pHead = nodePointers.pNext;
80 if (nodePointers.pNext) {
82 nextPointers.pPrevious = nodePointers.pPrevious;
83 }
else if (this->_pTail == &node) {
84 this->_pTail = nodePointers.pPrevious;
87 nodePointers.pPrevious =
nullptr;
88 nodePointers.pNext =
nullptr;
100 nodePointers.pPrevious = &after;
101 nodePointers.pNext = afterPointers.pNext;
102 afterPointers.pNext = &node;
104 if (nodePointers.pNext) {
106 nextPointers.pPrevious = &node;
109 if (this->_pTail == &after) {
110 this->_pTail = &node;
125 nodePointers.pPrevious = beforePointers.pPrevious;
126 nodePointers.pNext = &before;
127 beforePointers.pPrevious = &node;
129 if (nodePointers.pPrevious) {
131 nodePointers.pPrevious->*Pointers;
132 previousPointers.pNext = &node;
135 if (this->_pHead == &before) {
136 this->_pHead = &node;
149 (this->_pHead->*Pointers).pPrevious = &node;
150 (node.*Pointers).pNext = this->_pHead;
152 this->_pTail = &node;
154 this->_pHead = &node;
166 (this->_pTail->*Pointers).pNext = &node;
167 (node.*Pointers).pPrevious = this->_pTail;
169 this->_pHead = &node;
171 this->_pTail = &node;
179 size_t size() const noexcept {
return this->_size; }
185 T*
head() noexcept {
return this->_pHead; }
188 const T*
head() const noexcept {
return this->_pHead; }
194 T*
tail() noexcept {
return this->_pTail; }
197 const T*
tail() const noexcept {
return this->_pTail; }
203 T*
next(T& node) noexcept {
return (node.*Pointers).pNext; }
206 const T*
next(
const T& node)
const noexcept {
return (node.*Pointers).pNext; }
213 return pNode ? this->
next(*pNode) : this->_pHead;
217 const T*
next(
const T* pNode)
const noexcept {
218 return pNode ? this->
next(*pNode) : this->_pHead;
225 T*
previous(T& node) noexcept {
return (node.*Pointers).pPrevious; }
229 return (node.*Pointers).pPrevious;
237 return pNode ? this->
previous(*pNode) : this->_pTail;
242 return pNode ? this->
previous(*pNode) : this->_pTail;
257 return this->
next(node) !=
nullptr || this->
previous(node) !=
nullptr ||
258 this->_pHead == &node;
267 template <typename T, DoublyLinkedListPointers<T>(T::*Pointers)>
268 using DoublyLinkedList = DoublyLinkedListAdvanced<T, T, Pointers>;
const T * next(const T &node) const noexcept
Returns the next node after the given one, or nullptr if the given node is the tail.
void insertAtHead(T &node) noexcept
Insert the given node as the new head of the list.
void insertAfter(T &after, T &node) noexcept
Insert the given node after the other node.
const T * previous(const T &node) const noexcept
Returns the previous node before the given one, or nullptr if the given node is the head.
T * previous(T *pNode)
Returns the previous node before the given one, or the tail if the given node is nullptr.
void insertBefore(T &before, T &node) noexcept
Insert the given node before the other node.
size_t size() const noexcept
Returns the size of this list.
void remove(T &node) noexcept
Removes the given node from this list.
const T * next(const T *pNode) const noexcept
Returns the next node after the given one, or the head if the given node is nullptr.
T * next(T *pNode) noexcept
Returns the next node after the given one, or the head if the given node is nullptr.
const T * head() const noexcept
Returns the head node of this list, or nullptr if the list is empty.
T * previous(T &node) noexcept
Returns the previous node before the given one, or nullptr if the given node is the head.
const T * previous(const T *pNode) const noexcept
Returns the previous node before the given one, or the tail if the given node is nullptr.
bool contains(const T &node) const
Determines if this list contains a given node in constant time. In order to avoid a full list scan,...
T * next(T &node) noexcept
Returns the next node after the given one, or nullptr if the given node is the tail.
const T * tail() const noexcept
Returns the tail node of this list, or nullptr if the list is empty.
T * tail() noexcept
Returns the tail node of this list, or nullptr if the list is empty.
void insertAtTail(T &node) noexcept
Insert the given node as the new tail of the list.
T * head() noexcept
Returns the head node of this list, or nullptr if the list is empty.
Contains the previous and next pointers for an element in a DoublyLinkedList.
DoublyLinkedListPointers(DoublyLinkedListPointers &rhs) noexcept
Copy constructor.
DoublyLinkedListPointers() noexcept
Default constructor.
DoublyLinkedListPointers & operator=(const DoublyLinkedListPointers &) noexcept
Assignment operator.
Utility classes for Cesium.