41 typename TElementBase,
61 typename TPointerBase,
62 DoublyLinkedListPointers<T>(TPointerBase::*Pointers)>
71 if (nodePointers.pPrevious) {
73 nodePointers.pPrevious->*Pointers;
74 previousPointers.pNext = nodePointers.pNext;
76 }
else if (this->_pHead == &node) {
77 this->_pHead = nodePointers.pNext;
81 if (nodePointers.pNext) {
83 nextPointers.pPrevious = nodePointers.pPrevious;
84 }
else if (this->_pTail == &node) {
85 this->_pTail = nodePointers.pPrevious;
88 nodePointers.pPrevious =
nullptr;
89 nodePointers.pNext =
nullptr;
101 nodePointers.pPrevious = &after;
102 nodePointers.pNext = afterPointers.pNext;
103 afterPointers.pNext = &node;
105 if (nodePointers.pNext) {
107 nextPointers.pPrevious = &node;
110 if (this->_pTail == &after) {
111 this->_pTail = &node;
126 nodePointers.pPrevious = beforePointers.pPrevious;
127 nodePointers.pNext = &before;
128 beforePointers.pPrevious = &node;
130 if (nodePointers.pPrevious) {
132 nodePointers.pPrevious->*Pointers;
133 previousPointers.pNext = &node;
136 if (this->_pHead == &before) {
137 this->_pHead = &node;
150 (this->_pHead->*Pointers).pPrevious = &node;
151 (node.*Pointers).pNext = this->_pHead;
153 this->_pTail = &node;
155 this->_pHead = &node;
167 (this->_pTail->*Pointers).pNext = &node;
168 (node.*Pointers).pPrevious = this->_pTail;
170 this->_pHead = &node;
172 this->_pTail = &node;
180 size_t size() const noexcept {
return this->_size; }
186 T*
head() noexcept {
return this->_pHead; }
189 const T*
head() const noexcept {
return this->_pHead; }
195 T*
tail() noexcept {
return this->_pTail; }
198 const T*
tail() const noexcept {
return this->_pTail; }
204 T*
next(T& node)
noexcept {
return (node.*Pointers).pNext; }
207 const T*
next(
const T& node)
const noexcept {
return (node.*Pointers).pNext; }
214 return pNode ? this->
next(*pNode) : this->_pHead;
218 const T*
next(
const T* pNode)
const noexcept {
219 return pNode ? this->
next(*pNode) : this->_pHead;
226 T*
previous(T& node)
noexcept {
return (node.*Pointers).pPrevious; }
230 return (node.*Pointers).pPrevious;
238 return pNode ? this->
previous(*pNode) : this->_pTail;
243 return pNode ? this->
previous(*pNode) : this->_pTail;
258 return this->
next(node) !=
nullptr || this->
previous(node) !=
nullptr ||
259 this->_pHead == &node;
271template <typename T, DoublyLinkedListPointers<T>(T::*Pointers)>
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 * head() const noexcept
Returns the head node of this list, or nullptr if the list is empty.
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.
T * next(T *pNode) noexcept
Returns the next node after the given one, or the head if the given node is nullptr.
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 * head() noexcept
Returns the head node of this list, or nullptr if the list is empty.
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.
T * previous(T &node) noexcept
Returns the previous node before the given one, or nullptr if the given node is the head.
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.
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.
const T * tail() const noexcept
Returns the tail node of this list, or nullptr if the list is empty.
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.
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 * previous(T *pNode)
Returns the previous node before the given one, or the tail if the given node is nullptr.
Contains the previous and next pointers for an element in a DoublyLinkedList.
DoublyLinkedListPointers(DoublyLinkedListPointers &rhs) noexcept
Copy constructor.
DoublyLinkedListPointers & operator=(const DoublyLinkedListPointers &) noexcept
Assignment operator.
DoublyLinkedListPointers() noexcept
Default constructor.
Utility classes for Cesium.