12 #ifndef ESTD_INTRUSIVELIST_HPP_ 13 #define ESTD_INTRUSIVELIST_HPP_ 25 class IntrusiveListBase;
82 if (other.isLinked() ==
false)
159 const auto thisWasLinked =
isLinked();
160 const auto otherWasLinked = other.
isLinked();
162 if (thisWasLinked ==
true || otherWasLinked ==
true)
168 if (thisWasLinked ==
true)
173 if (otherWasLinked ==
true)
292 while (
empty() ==
false)
402 newNode.
link(position, {});
416 insert(position, splicedNode);
455 template<
typename T, IntrusiveListNode T::* NodePo
inter,
typename U = T>
504 node_{&(element.*NodePointer)}
506 static_assert(std::is_same<U, T>::value ==
true || std::is_convertible<U*, T*>::value ==
true,
507 "U* must be implicitly convertible to T*!");
552 const auto temporary = *
this;
577 const auto temporary = *
this;
605 static_assert(std::is_same<U, T>::value ==
true || std::is_convertible<U*, T*>::value ==
true,
606 "U* must be implicitly convertible to T*!");
608 const auto offset = reinterpret_cast<size_t>(&(static_cast<pointer>(
nullptr)->*NodePointer));
609 return reinterpret_cast<pointer>(reinterpret_cast<size_t>(
node_) - offset);
630 template<
typename T, IntrusiveListNode T::* NodePo
inter,
typename U = T>
634 return (left == right) ==
false;
648 template<
typename T, const IntrusiveListNode T::* NodePo
inter,
typename U = T>
697 node_{&(element.*NodePointer)}
699 static_assert(std::is_same<U, T>::value ==
true || std::is_convertible<U*, T*>::value ==
true,
700 "U* must be implicitly convertible to T*!");
713 template<IntrusiveListNode T::* NonConstNodePo
inter>
762 const auto temporary = *
this;
787 const auto temporary = *
this;
815 static_assert(std::is_same<U, T>::value ==
true || std::is_convertible<U*, T*>::value ==
true,
816 "U* must be implicitly convertible to T*!");
818 const auto offset = reinterpret_cast<size_t>(&(static_cast<pointer>(
nullptr)->*NodePointer));
819 return reinterpret_cast<pointer>(reinterpret_cast<size_t>(
node_) - offset);
840 template<
typename T, const IntrusiveListNode T::* NodePo
inter,
typename U = T>
844 return (left == right) ==
false;
862 template<
typename T, IntrusiveListNode T::* NodePo
inter, const IntrusiveListNode T::* ConstNodePo
inter,
typename U = T>
866 return decltype(right){left} == right;
884 template<
typename T, IntrusiveListNode T::* NodePo
inter, const IntrusiveListNode T::* ConstNodePo
inter,
typename U = T>
888 return (left == right) ==
false;
906 template<
typename T, IntrusiveListNode T::* NodePo
inter, const IntrusiveListNode T::* ConstNodePo
inter,
typename U = T>
910 return right != left;
926 template<
typename T, IntrusiveListNode T::* NodePo
inter,
typename U = T>
1196 auto& positionNode = (*position).*NodePointer;
1214 static_assert(std::is_same<U, T>::value ==
true || std::is_convertible<U*, T*>::value ==
true,
1215 "U* must be implicitly convertible to T*!");
1217 auto& positionNode = (*position).*NodePointer;
1218 auto& newElementNode = newElement.*NodePointer;
1234 auto& positionNode = (*position).*NodePointer;
1235 auto& splicedElementNode = (*splicedElement).*NodePointer;
1262 template<
typename T, IntrusiveListNode T::* NodePo
inter,
typename U = T>
1270 #endif // ESTD_INTRUSIVELIST_HPP_ void push_back(reference newElement)
Links the element at the end of the list.
Definition: IntrusiveList.hpp:1119
Collection of useful templates.
Definition: DmaChannel.hpp:121
IntrusiveList class is an intrusive circular doubly linked list.
Definition: IntrusiveList.hpp:927
std::bidirectional_iterator_tag iterator_category
category of the iterator
Definition: IntrusiveList.hpp:464
const_reference back() const
Definition: IntrusiveList.hpp:981
IntrusiveListIterator operator++(int)
IntrusiveListIterator's unary postfix increment operator.
Definition: IntrusiveList.hpp:550
U & reference
reference to object "pointed to" by the iterator
Definition: IntrusiveList.hpp:470
const MutexControlBlock * const_pointer
const pointer to value linked in the list
Definition: IntrusiveList.hpp:938
IntrusiveListNode * nextNode_
reference to next node on the list
Definition: IntrusiveList.hpp:209
MutexControlBlock & reference
reference to value linked in the list
Definition: IntrusiveList.hpp:953
IntrusiveListNode * previousNode_
reference to previous node on the list
Definition: IntrusiveList.hpp:212
const_iterator begin() const
Definition: IntrusiveList.hpp:999
std::bidirectional_iterator_tag iterator_category
category of the iterator
Definition: IntrusiveList.hpp:657
IntrusiveListNode & getPreviousNode() const
Definition: IntrusiveList.hpp:118
const IntrusiveListNode & begin() const
Definition: IntrusiveList.hpp:263
const_iterator cend() const
Definition: IntrusiveList.hpp:1017
constexpr IntrusiveListConstIterator(reference element)
IntrusiveListConstIterator's constructor.
Definition: IntrusiveList.hpp:696
internal::IntrusiveListBase intrusiveListBase_
internal IntrusiveListBase object
Definition: IntrusiveList.hpp:1247
constexpr LinkAccessKey()
LinkAccessKey's constructor.
Definition: IntrusiveList.hpp:52
bool empty() const
Definition: IntrusiveList.hpp:1054
bool operator==(const IntrusiveListConstIterator &other) const
IntrusiveListConstIterator's "equal to" comparison operator.
Definition: IntrusiveList.hpp:800
const_iterator cbegin() const
Definition: IntrusiveList.hpp:1008
MutexControlBlock * pointer
pointer to value linked in the list
Definition: IntrusiveList.hpp:950
pointer getPointer() const
Converts contained pointer to IntrusiveListNode to pointer to object that contains this node.
Definition: IntrusiveList.hpp:603
IntrusiveListIterator & operator++()
IntrusiveListIterator's unary prefix increment operator.
Definition: IntrusiveList.hpp:538
IntrusiveListConstIterator class is a const iterator of elements on IntrusiveList.
Definition: IntrusiveList.hpp:649
U * pointer
pointer to object "pointed to" by the iterator
Definition: IntrusiveList.hpp:467
const IntrusiveListNode * node_
pointer to const IntrusiveListNode of the object "pointed to" by the iterator
Definition: IntrusiveList.hpp:823
constexpr IntrusiveListIterator()
IntrusiveListIterator's constructor.
Definition: IntrusiveList.hpp:479
constexpr IntrusiveListNode()
IntrusiveListNode's constructor.
Definition: IntrusiveList.hpp:67
void swap(IntrusiveListNode &other)
Swaps contents with another node.
Definition: IntrusiveList.hpp:157
void swap(IntrusiveList< T, NodePointer, U > &left, IntrusiveList< T, NodePointer, U > &right)
Swaps contents of two lists.
Definition: IntrusiveList.hpp:1263
~IntrusiveListNode()
IntrusiveListNode's destructor.
Definition: IntrusiveList.hpp:100
bool operator==(const IntrusiveListIterator &other) const
IntrusiveListIterator's "equal to" comparison operator.
Definition: IntrusiveList.hpp:590
void pop_front()
Unlinks the first node from the list.
Definition: IntrusiveList.hpp:336
static void insert(IntrusiveListNode &position, IntrusiveListNode &newNode)
Links the node in the list before position.
Definition: IntrusiveList.hpp:400
void push_front(IntrusiveListNode &newNode)
Links the node at the beginning of the list.
Definition: IntrusiveList.hpp:358
const IntrusiveListNode & cbegin() const
Definition: IntrusiveList.hpp:272
MutexControlBlock value_type
value linked in the list
Definition: IntrusiveList.hpp:956
void reset()
Resets the node to the same state as right after construction.
Definition: IntrusiveList.hpp:202
void swap(IntrusiveList &other)
Swaps contents with another list.
Definition: IntrusiveList.hpp:1179
reverse_iterator rend()
Definition: IntrusiveList.hpp:1158
iterator end()
Definition: IntrusiveList.hpp:1063
IntrusiveListNode class is the node that is needed for the object to be linked in IntrusiveList.
Definition: IntrusiveList.hpp:38
IntrusiveListNode & end()
Definition: IntrusiveList.hpp:309
bool operator!=(const IntrusiveForwardListIterator< T, NodePointer, U > &left, const IntrusiveForwardListIterator< T, NodePointer, U > &right)
IntrusiveForwardListIterator's "not equal to" comparison operator.
Definition: IntrusiveForwardList.hpp:578
reference operator *() const
IntrusiveListIterator's unary prefix dereference operator.
Definition: IntrusiveList.hpp:527
IntrusiveListConstIterator & operator--()
IntrusiveListConstIterator's unary prefix decrement operator.
Definition: IntrusiveList.hpp:773
bool empty() const
Definition: IntrusiveList.hpp:300
void push_back(IntrusiveListNode &newNode)
Links the node at the end of the list.
Definition: IntrusiveList.hpp:347
const_reverse_iterator crend() const
Definition: IntrusiveList.hpp:1045
constexpr IntrusiveListConstIterator()
IntrusiveListConstIterator's constructor.
Definition: IntrusiveList.hpp:672
IntrusiveListBase class provides base functionalities for IntrusiveList class, but without any knowle...
Definition: IntrusiveList.hpp:225
void swap(IntrusiveListBase &other)
Swaps contents with another list.
Definition: IntrusiveList.hpp:369
static IntrusiveListNode & erase(IntrusiveListNode &position)
Unlinks the node at position from the list.
Definition: IntrusiveList.hpp:384
Definition: IntrusiveList.hpp:44
void pop_back()
Unlinks the last node from the list.
Definition: IntrusiveList.hpp:327
void clear()
Unlinks all elements from the list.
Definition: IntrusiveList.hpp:1026
void unlink()
Unlinks the node from the list.
Definition: IntrusiveList.hpp:184
static void splice(const iterator position, const iterator splicedElement)
Transfers the element from one list to another list before position.
Definition: IntrusiveList.hpp:1232
U value_type
value "pointed to" by the iterator
Definition: IntrusiveList.hpp:473
U value_type
value "pointed to" by the iterator
Definition: IntrusiveList.hpp:666
const_reverse_iterator rbegin() const
Definition: IntrusiveList.hpp:1148
std::reverse_iterator< const_iterator > const_reverse_iterator
const reverse iterator of elements on the list
Definition: IntrusiveList.hpp:935
IntrusiveListConstIterator operator--(int)
IntrusiveListConstIterator's unary postfix decrement operator.
Definition: IntrusiveList.hpp:785
void link(IntrusiveListNode &position, LinkAccessKey)
Links the node in the list before position.
Definition: IntrusiveList.hpp:141
~IntrusiveListBase()
IntrusiveListBase's destructor.
Definition: IntrusiveList.hpp:245
IntrusiveListNode(IntrusiveListNode &&other)
IntrusiveListNode's move constructor.
Definition: IntrusiveList.hpp:80
IntrusiveListConstIterator operator++(int)
IntrusiveListConstIterator's unary postfix increment operator.
Definition: IntrusiveList.hpp:760
const_reverse_iterator crbegin() const
Definition: IntrusiveList.hpp:1035
pointer getPointer() const
Converts contained pointer to IntrusiveListNode to pointer to object that contains this node.
Definition: IntrusiveList.hpp:813
static void splice(IntrusiveListNode &position, IntrusiveListNode &splicedNode)
Transfers the node from one list to another list before position.
Definition: IntrusiveList.hpp:414
const_reference front() const
Definition: IntrusiveList.hpp:1090
IntrusiveListNode & getNextNode() const
Definition: IntrusiveList.hpp:109
constexpr IntrusiveListIterator(reference element)
IntrusiveListIterator's constructor.
Definition: IntrusiveList.hpp:503
bool isLinked() const
Definition: IntrusiveList.hpp:127
IntrusiveListNode & begin()
Definition: IntrusiveList.hpp:254
void push_front(reference newElement)
Links the element at the beginning of the list.
Definition: IntrusiveList.hpp:1130
iterator begin()
Definition: IntrusiveList.hpp:990
pointer operator->() const
IntrusiveListConstIterator's binary infix pointer member access operator.
Definition: IntrusiveList.hpp:726
const IntrusiveListNode & end() const
Definition: IntrusiveList.hpp:318
IntrusiveListNode * node_
pointer to IntrusiveListNode of the object "pointed to" by the iterator
Definition: IntrusiveList.hpp:613
constexpr IntrusiveListBase()
IntrusiveListBase's constructor.
Definition: IntrusiveList.hpp:233
ptrdiff_t difference_type
difference type
Definition: IntrusiveList.hpp:654
constexpr IntrusiveListConstIterator(const IntrusiveListNode *const node)
IntrusiveListConstIterator's constructor.
Definition: IntrusiveList.hpp:684
reference back()
Definition: IntrusiveList.hpp:972
void swap(IntrusiveForwardListNode &left, IntrusiveForwardListNode &right)
Swaps contents of two nodes.
Definition: IntrusiveForwardList.hpp:172
constexpr IntrusiveListIterator(IntrusiveListNode *const node)
IntrusiveListIterator's constructor.
Definition: IntrusiveList.hpp:491
const_iterator end() const
Definition: IntrusiveList.hpp:1072
pointer operator->() const
IntrusiveListIterator's binary infix pointer member access operator.
Definition: IntrusiveList.hpp:516
reference operator *() const
IntrusiveListConstIterator's unary prefix dereference operator.
Definition: IntrusiveList.hpp:737
void pop_back()
Unlinks the last element from the list.
Definition: IntrusiveList.hpp:1099
const MutexControlBlock & const_reference
const reference to value linked in the list
Definition: IntrusiveList.hpp:941
IntrusiveListConstIterator & operator++()
IntrusiveListConstIterator's unary prefix increment operator.
Definition: IntrusiveList.hpp:748
IntrusiveListIterator operator--(int)
IntrusiveListIterator's unary postfix decrement operator.
Definition: IntrusiveList.hpp:575
static iterator erase(const iterator position)
Unlinks the element at position from the list.
Definition: IntrusiveList.hpp:1194
void pop_front()
Unlinks the first element from the list.
Definition: IntrusiveList.hpp:1108
reference front()
Definition: IntrusiveList.hpp:1081
IntrusiveListNode rootNode_
root node of the intrusive list
Definition: IntrusiveList.hpp:427
bool operator==(const IntrusiveForwardListIterator< T, NodePointer, U > &left, const IntrusiveForwardListConstIterator< T, ConstNodePointer, U > &right)
"Equal to" comparison operator for IntrusiveForwardListIterator and IntrusiveForwardListConstIterator
Definition: IntrusiveForwardList.hpp:789
const U * pointer
pointer to object "pointed to" by the iterator
Definition: IntrusiveList.hpp:660
const_reverse_iterator rend() const
Definition: IntrusiveList.hpp:1168
IntrusiveListIterator & operator--()
IntrusiveListIterator's unary prefix decrement operator.
Definition: IntrusiveList.hpp:563
void clear()
Unlinks all nodes from the list.
Definition: IntrusiveList.hpp:290
static iterator insert(const iterator position, reference newElement)
Links the element in the list before position.
Definition: IntrusiveList.hpp:1212
std::reverse_iterator< iterator > reverse_iterator
reverse iterator of elements on the list
Definition: IntrusiveList.hpp:947
void swap(IntrusiveForwardListBase &left, IntrusiveForwardListBase &right)
Swaps contents of two lists.
Definition: IntrusiveForwardList.hpp:409
constexpr IntrusiveListConstIterator(const IntrusiveListIterator< T, NonConstNodePointer, U > &iterator)
IntrusiveListConstIterator's constructor.
Definition: IntrusiveList.hpp:714
ptrdiff_t difference_type
difference type
Definition: IntrusiveList.hpp:461
const U & reference
reference to object "pointed to" by the iterator
Definition: IntrusiveList.hpp:663
reverse_iterator rbegin()
Definition: IntrusiveList.hpp:1139
constexpr IntrusiveList()
IntrusiveList's constructor.
Definition: IntrusiveList.hpp:962
IntrusiveListIterator class is an iterator of elements on IntrusiveList.
Definition: IntrusiveList.hpp:456
const IntrusiveListNode & cend() const
Definition: IntrusiveList.hpp:281