18 #ifndef RAUL_LIST_IMPL_HPP
19 #define RAUL_LIST_IMPL_HPP
39 Node* node = _head.get();
72 ln->prev(_tail.get());
73 _tail.get()->next(ln);
100 ln->prev(_tail.get());
101 _tail.get()->next(ln);
117 template <
typename T>
121 Node*
const my_head = _head.get();
122 Node*
const my_tail = _tail.get();
123 Node*
const other_head = list._head.get();
124 Node*
const other_tail = list._tail.get();
126 assert((my_head && my_tail) || (!my_head && !my_tail));
127 assert((other_head && other_tail) || (!other_head && !other_tail));
130 if (my_head == NULL && my_tail == NULL) {
134 }
else if (other_head != NULL && other_tail != NULL) {
136 other_head->prev(my_tail);
141 my_tail->next(other_head);
143 _size += list.
size();
156 template <
typename T>
160 for (
iterator i = begin(); i != end(); ++i)
175 template <
typename T>
179 assert((_head.get() && _tail.get()) || (!_head.get() && !_tail.get()));
181 Node*
const n = iter._listnode;
184 Node*
const prev = n->prev();
185 Node*
const next = n->next();
188 if (n == _head.get())
192 if (n == _tail.get())
193 _tail = _tail.get()->prev();
196 n->prev()->next(next);
199 n->next()->prev(prev);
204 assert((_head.get() && _tail.get()) || (!_head.get() && !_tail.get()));
209 template <
typename T>
214 assert((front._head.get() && front._tail.get()) || (!front._head.get() && !front._tail.get()));
215 assert((_head.get() && _tail.get()) || (!_head.get() && !_tail.get()));
216 front._size = front_size;
218 front._tail = front_tail;
219 Node* new_head = front_tail->next();
221 new_head->prev(NULL);
229 front_tail->next(NULL);
230 assert((front._head.get() && front._tail.get()) || (!front._head.get() && !front._tail.get()));
231 assert((_head.get() && _tail.get()) || (!_head.get() && !_tail.get()));
237 template <
typename T>
238 List<T>::iterator::iterator(List<T>* list)
245 template <
typename T>
247 List<T>::iterator::operator*()
250 return _listnode->elem();
254 template <
typename T>
256 List<T>::iterator::operator->()
259 return &_listnode->elem();
263 template <
typename T>
264 inline typename List<T>::iterator&
265 List<T>::iterator::operator++()
268 _listnode = _listnode->next();
274 template <
typename T>
276 List<T>::iterator::operator!=(
const iterator& iter)
const
278 return (_listnode != iter._listnode);
282 template <
typename T>
284 List<T>::iterator::operator!=(
const const_iterator& iter)
const
286 return (_listnode != iter._listnode);
290 template <
typename T>
292 List<T>::iterator::operator==(
const iterator& iter)
const
294 return (_listnode == iter._listnode);
298 template <
typename T>
300 List<T>::iterator::operator==(
const const_iterator& iter)
const
302 return (_listnode == iter._listnode);
306 template <
typename T>
307 inline typename List<T>::iterator
310 typename List<T>::iterator iter(
this);
312 iter._listnode = _head.get();
318 template <
typename T>
319 inline const typename List<T>::iterator
330 template <
typename T>
338 template <
typename T>
343 return _listnode->elem();
347 template <
typename T>
352 return &_listnode->elem();
356 template <
typename T>
357 inline typename List<T>::const_iterator&
358 List<T>::const_iterator::operator++()
361 _listnode = _listnode->next();
367 template <
typename T>
369 List<T>::const_iterator::operator!=(
const const_iterator& iter)
const
371 return (_listnode != iter._listnode);
375 template <
typename T>
377 List<T>::const_iterator::operator!=(
const iterator& iter)
const
379 return (_listnode != iter._listnode);
383 template <
typename T>
385 List<T>::const_iterator::operator==(
const const_iterator& iter)
const
387 return (_listnode == iter._listnode);
391 template <
typename T>
393 List<T>::const_iterator::operator==(
const iterator& iter)
const
395 return (_listnode == iter._listnode);
398 template <
typename T>
399 inline typename List<T>::const_iterator
400 List<T>::begin()
const
402 typename List<T>::const_iterator iter(
this);
403 iter._listnode = _head.get();
411 #endif // RAUL_LIST_IMPL_HPP
void clear()
Clear the list, deleting all Nodes contained (but NOT their contents!)
Definition: ListImpl.hpp:37
Realtime safe iterator for a List.
Definition: List.hpp:130
unsigned size() const
Valid only in the write thread.
Definition: List.hpp:96
A node in a List.
Definition: List.hpp:51
A realtime safe, (partially) thread safe doubly-linked list.
Definition: List.hpp:41
void append(List< T > &list)
Append a list to this list.
Definition: ListImpl.hpp:119
Node * erase(const iterator iter)
Remove an element from the list using an iterator.
Definition: ListImpl.hpp:177
void push_back(Node *elem)
Realtime Safe.
Definition: ListImpl.hpp:61
iterator find(const T &val)
Find an element in the list.
Definition: ListImpl.hpp:158
const_iterator(const List< T > *const list)
const_iterator stuff ///
Definition: ListImpl.hpp:331