1#ifndef CONTAINER_INTRUSIVE_LIST_H_INCLUDED
2#define CONTAINER_INTRUSIVE_LIST_H_INCLUDED
5#ifndef CPPELIB_NO_STD_ITERATOR
22 template <
typename T,
typename Ref,
typename Ptr,
typename IntrusiveListNodePtr>
35template <
typename T,
typename Ref,
typename Ptr,
typename IntrusiveListNodePtr>
47#ifndef CPPELIB_NO_STD_ITERATOR
64 m_node = m_node->m_nextListNode;
71 m_node = m_node->m_prevListNode;
92 return *
static_cast<pointer>(m_node);
98 return static_cast<pointer>(m_node);
103 return m_node == x.m_node;
108 return !(*
this == x);
112 template <
typename U>
115 template <
typename U,
typename RefX,
typename PtrX,
typename IntrusiveListNodePtrX>
118 IntrusiveListNodePtr m_node;
142#ifndef CPPELIB_NO_STD_ITERATOR
149 m_terminator.m_nextListNode = &m_terminator;
150 m_terminator.m_prevListNode = &m_terminator;
155 return m_terminator.m_nextListNode == &m_terminator;
169 return iterator(m_terminator.m_nextListNode);
187#ifndef CPPELIB_NO_STD_ITERATOR
258 data.m_nextListNode =
pos.m_node;
259 data.m_prevListNode =
pos.m_node->m_prevListNode;
260 pos.m_node->m_prevListNode = &data;
261 data.m_prevListNode->m_nextListNode = &data;
270 pos.m_node->m_prevListNode->m_nextListNode =
pos.m_node->m_nextListNode;
271 pos.m_node->m_nextListNode->m_prevListNode =
pos.m_node->m_prevListNode;
313 last.m_node->m_prevListNode->m_nextListNode =
pos.m_node;
314 first.m_node->m_prevListNode->m_nextListNode =
last.m_node;
315 pos.m_node->m_prevListNode->m_nextListNode =
first.m_node;
318 pos.m_node->m_prevListNode =
last.m_node->m_prevListNode;
319 last.m_node->m_prevListNode =
first.m_node->m_prevListNode;
325 if (
this == &
other) {
#define DEBUG_ASSERT(x)
The same as CHECK_ASSERT() macro.
Definition Assertion.h:39
Base class of the type of element of IntrusiveList.
Definition IntrusiveList.h:17
IntrusiveListNode()
Definition IntrusiveList.h:29
Bidirectional iterator used as IntrusiveList<T>::iterator or IntrusiveList<T>::const_iterator.
Definition IntrusiveList.h:36
std::ptrdiff_t difference_type
Definition IntrusiveList.h:40
reference operator*() const
Definition IntrusiveList.h:89
IntrusiveList_iterator(const iterator &x)
Definition IntrusiveList.h:53
Ptr pointer
Definition IntrusiveList.h:45
bool operator==(const IntrusiveList_iterator &x) const
Definition IntrusiveList.h:101
std::bidirectional_iterator_tag iterator_category
Definition IntrusiveList.h:48
IntrusiveList_iterator & operator--()
Definition IntrusiveList.h:68
pointer operator->() const
Definition IntrusiveList.h:95
Ref reference
Definition IntrusiveList.h:43
std::size_t size_type
Definition IntrusiveList.h:39
IntrusiveList_iterator operator++(int)
Definition IntrusiveList.h:75
friend class IntrusiveList_iterator
Definition IntrusiveList.h:116
IntrusiveList_iterator & operator++()
Definition IntrusiveList.h:61
IntrusiveList_iterator operator--(int)
Definition IntrusiveList.h:82
IntrusiveList_iterator< T, T &, T *, IntrusiveListNode * > iterator
Definition IntrusiveList.h:41
const Ref const_reference
Definition IntrusiveList.h:44
IntrusiveList_iterator< T, const T &, const T *, const IntrusiveListNode * > const_iterator
Definition IntrusiveList.h:42
const Ptr const_pointer
Definition IntrusiveList.h:46
IntrusiveList_iterator & operator=(const iterator &x)
Definition IntrusiveList.h:55
IntrusiveList_iterator()
Definition IntrusiveList.h:51
T value_type
Definition IntrusiveList.h:38
bool operator!=(const IntrusiveList_iterator &x) const
Definition IntrusiveList.h:106
STL-like intrusive doubly linked list.
Definition IntrusiveList.h:131
reverse_iterator rend()
Definition IntrusiveList.h:198
std::size_t size_type
Definition IntrusiveList.h:134
void splice(iterator pos, IntrusiveList &x, iterator first, iterator last)
Definition IntrusiveList.h:299
const_iterator begin() const
Definition IntrusiveList.h:172
std::reverse_iterator< iterator > reverse_iterator
Definition IntrusiveList.h:143
reference front()
Definition IntrusiveList.h:209
const_reference back() const
Definition IntrusiveList.h:227
void push_back(T &data)
Definition IntrusiveList.h:233
void splice(iterator pos, IntrusiveList &x, iterator i)
Definition IntrusiveList.h:284
const value_type * const_pointer
Definition IntrusiveList.h:141
const value_type & const_reference
Definition IntrusiveList.h:139
IntrusiveList_iterator< T, T &, T *, IntrusiveListNode * > iterator
Definition IntrusiveList.h:136
const_iterator end() const
Definition IntrusiveList.h:182
value_type * pointer
Definition IntrusiveList.h:140
iterator erase(iterator pos)
Definition IntrusiveList.h:265
void splice(iterator pos, IntrusiveList &x)
Definition IntrusiveList.h:275
void swap(IntrusiveList &other)
Definition IntrusiveList.h:323
const_reference front() const
Definition IntrusiveList.h:215
value_type & reference
Definition IntrusiveList.h:138
reverse_iterator rbegin()
Definition IntrusiveList.h:188
void pop_back()
Definition IntrusiveList.h:238
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition IntrusiveList.h:144
const_reverse_iterator rend() const
Definition IntrusiveList.h:203
void pop_front()
Definition IntrusiveList.h:249
IntrusiveList()
Definition IntrusiveList.h:147
bool empty() const
Definition IntrusiveList.h:153
iterator begin()
Definition IntrusiveList.h:167
std::ptrdiff_t difference_type
Definition IntrusiveList.h:135
const_reverse_iterator rbegin() const
Definition IntrusiveList.h:193
T value_type
Definition IntrusiveList.h:133
void push_front(T &data)
Definition IntrusiveList.h:244
IntrusiveList_iterator< T, const T &, const T *, const IntrusiveListNode * > const_iterator
Definition IntrusiveList.h:137
iterator insert(iterator pos, T &data)
Definition IntrusiveList.h:255
reference back()
Definition IntrusiveList.h:221
size_type size() const
Definition IntrusiveList.h:158
iterator end()
Definition IntrusiveList.h:177
void swap(IntrusiveList< T > &x, IntrusiveList< T > &y)
Definition IntrusiveList.h:342