9#include <AH/Debug/Debug.hpp>
13#include <AH/STL/iterator>
28 template <
class INode>
38 return !(*
this != rhs);
56 template <
class INode>
83 template <
class INode>
121 if (
first ==
nullptr)
123 node->previous =
last;
124 if (node->previous !=
nullptr)
125 node->previous->next = node;
127 node->next =
nullptr;
149 first = toBeInserted;
151 before->previous->next = toBeInserted;
152 toBeInserted->previous = before->previous;
153 toBeInserted->next = before;
154 before->previous = toBeInserted;
172 template <
class Compare>
177 if (cmp(*node, *it)) {
194 insertSorted(node, [](Node &lhs, Node &rhs) {
return lhs < rhs; });
204 if (node->previous !=
nullptr)
205 node->previous->next = node->next;
207 last = node->previous;
208 if (node->next !=
nullptr)
209 node->next->previous = node->previous;
212 node->previous =
nullptr;
213 node->next =
nullptr;
236 Node *nodeB = node->previous;
237 if (nodeB ==
nullptr)
239 Node *nodeA = nodeB->previous;
240 Node *nodeD = node->next;
242 if (nodeA !=
nullptr)
247 nodeB->previous = node;
249 node->previous = nodeA;
250 if (nodeD !=
nullptr)
251 nodeD->previous = nodeB;
285 return node && (node ==
first || node->next !=
nullptr ||
286 node->previous !=
nullptr);
#define AH_DIAGNOSTIC_POP()
#define AH_DIAGNOSTIC_WERROR()
A class that can be inherited from to allow inserting into a DoublyLinkedList.
DoublyLinkable & operator=(const DoublyLinkable &)
virtual ~DoublyLinkable()=default
DoublyLinkable & operator=(DoublyLinkable &&)
DoublyLinkable(const DoublyLinkable &)
DoublyLinkable(DoublyLinkable &&)
Base class for doubly linked list iterators.
bool operator==(const node_iterator_base &rhs) const
INode & operator*() const
bool operator!=(const node_iterator_base &rhs) const
node_iterator_base(INode *node)
INode * operator->() const
Forward bidirectional doubly linked list iterator.
std::bidirectional_iterator_tag iterator_category
node_iterator & operator--()
Prefix decrement operator.
node_iterator & operator++()
Prefix increment operator.
node_iterator(INode *node)
Reverse bidirectional doubly linked list iterator.
reverse_node_iterator & operator++()
Prefix increment operator.
std::bidirectional_iterator_tag iterator_category
reverse_node_iterator & operator--()
Prefix decrement operator.
reverse_node_iterator(INode *node)
A class for doubly linked lists.
const_reverse_iterator rend() const
const_iterator begin() const
void append(Node *node)
Append a node to a linked list.
bool couldContain(const Node *node) const
Check if the linked list could contain the given node.
void remove(Node *node)
Remove a node from the linked list.
bool couldContain(const Node &node) const
Check if the linked list could contain the given node.
Node * getLast() const
Get a pointer to the last node.
void moveDown(Node &node)
Move down the given node in the linked list.
Node * getFirst() const
Get a pointer to the first node.
void append(Node &node)
Append a node to a linked list.
void moveDown(Node *node)
Move down the given node in the linked list.
void remove(Node &node)
Remove a node from the linked list.
void insertSorted(Node *node)
Insert a new node at the correct location into a sorted list, using operator<.
const_iterator end() const
reverse_iterator rbegin()
void insertBefore(Node *toBeInserted, Node *before)
Insert a node before another node.
void insertSorted(Node *node, Compare cmp)
Insert a new node at the correct location into a sorted list.
void insertBefore(Node &toBeInserted, Node &before)
const_reverse_iterator rbegin() const