25 #include "common/list_intern.h" 43 template<
typename t_T>
62 constexpr
List() : _anchor(&_anchor, &_anchor) {}
77 iterator
insert(iterator pos,
const t_T &element) {
78 insert(pos._node, element);
85 template<
typename iterator2>
86 void insert(iterator pos, iterator2 first, iterator2 last) {
87 for (; first != last; ++first)
105 assert(pos !=
end());
114 iterator
erase(iterator first, iterator last) {
115 NodeBase *f = first._node;
116 NodeBase *l = last._node;
125 void remove(
const t_T &val) {
126 NodeBase *i = _anchor._next;
127 while (i != &_anchor)
128 if (val == static_cast<Node *>(i)->_data)
136 insert(_anchor._next, element);
141 insert(&_anchor, element);
147 erase(_anchor._next);
153 erase(_anchor._prev);
158 return static_cast<Node *
>(_anchor._next)->_data;
163 return static_cast<Node *
>(_anchor._next)->_data;
168 return static_cast<Node *
>(_anchor._prev)->_data;
173 return static_cast<Node *
>(_anchor._prev)->_data;
180 const iterator e =
end();
182 const_iterator e2 = list.
end();
184 for (i =
begin(), i2 = list.
begin(); (i != e) && (i2 != e2); ++i, ++i2) {
185 static_cast<Node *
>(i._node)->_data = static_cast<const Node *>(i2._node)->_data;
200 for (
const NodeBase *cur = _anchor._next; cur != &_anchor; cur = cur->_next)
207 NodeBase *pos = _anchor._next;
208 while (pos != &_anchor) {
209 Node *node =
static_cast<Node *
>(pos);
220 return (&_anchor == _anchor._next);
261 const_iterator
end()
const {
271 Node *node =
static_cast<Node *
>(pos);
272 n._prev->_next = n._next;
273 n._next->_prev = n._prev;
281 void insert(NodeBase *pos,
const t_T &element) {
285 newNode->_next = pos;
286 newNode->_prev = pos->_prev;
287 newNode->_prev->_next = newNode;
288 newNode->_next->_prev = newNode;
void pop_front()
Definition: list.h:145
constexpr List()
Definition: list.h:62
iterator insert(iterator pos, const t_T &element)
Definition: list.h:77
Definition: list_intern.h:33
uint size_type
Definition: list.h:56
NodeBase erase(NodeBase *pos)
Definition: list.h:269
const_iterator begin() const
Definition: list.h:248
const_iterator reverse_begin() const
Definition: list.h:256
NodeBase _anchor
Definition: list.h:49
t_T value_type
Definition: list.h:55
const_iterator end() const
Definition: list.h:261
size_type size() const
Definition: list.h:198
void push_front(const t_T &element)
Definition: list.h:135
List(const List< t_T > &list)
Definition: list.h:63
t_T & back()
Definition: list.h:167
ListInternal::NodeBase NodeBase
Definition: list.h:46
void insert(NodeBase *pos, const t_T &element)
Definition: list.h:281
void insert(iterator pos, iterator2 first, iterator2 last)
Definition: list.h:86
iterator end()
Definition: list.h:240
iterator erase(iterator first, iterator last)
Definition: list.h:114
iterator begin()
Definition: list.h:227
Definition: algorithm.h:29
ListInternal::Iterator< t_T > iterator
Definition: list.h:52
void clear()
Definition: list.h:206
ListInternal::ConstIterator< t_T > const_iterator
Definition: list.h:53
const t_T & front() const
Definition: list.h:162
t_T & front()
Definition: list.h:157
List< t_T > & operator=(const List< t_T > &list)
Definition: list.h:177
Definition: list_intern.h:48
iterator reverse_begin()
Definition: list.h:235
Definition: list_intern.h:51
iterator erase(iterator pos)
Definition: list.h:95
iterator reverse_erase(iterator pos)
Definition: list.h:104
void push_back(const t_T &element)
Definition: list.h:140
void pop_back()
Definition: list.h:151
bool empty() const
Definition: list.h:219
Definition: list_intern.h:42
ListInternal::Node< t_T > Node
Definition: list.h:47
const t_T & back() const
Definition: list.h:172