9 #ifndef CPPCOMMON_CONTAINERS_LIST_H
10 #define CPPCOMMON_CONTAINERS_LIST_H
21 class ListConstIterator;
23 class ListReverseIterator;
25 class ListConstReverseIterator;
154 template <
typename T>
180 List() noexcept : _size(0), _front(
nullptr), _back(
nullptr) {}
181 template <
class InputIterator>
182 List(InputIterator first, InputIterator last) noexcept;
191 explicit operator
bool() const noexcept {
return !
empty(); }
194 bool empty() const noexcept {
return _front ==
nullptr; }
197 size_t size() const noexcept {
return _size; }
200 T*
front() noexcept {
return _front; }
201 const T*
front() const noexcept {
return _front; }
203 T*
back() noexcept {
return _back; }
204 const T*
back() const noexcept {
return _back; }
239 void push_next(T& base, T& item) noexcept;
245 void push_prev(T& base, T& item) noexcept;
280 void clear() noexcept;
284 template <typename U>
297 template <typename T>
323 {
return it1._node == it2._node; }
325 {
return it1._node != it2._node; }
334 explicit operator
bool() const noexcept {
return _node !=
nullptr; }
338 template <
typename U>
349 template <
typename T>
371 { _node = it._node;
return *
this; }
376 {
return it1._node == it2._node; }
378 {
return it1._node != it2._node; }
387 explicit operator
bool() const noexcept {
return _node !=
nullptr; }
391 template <
typename U>
402 template <
typename T>
428 {
return it1._node == it2._node; }
430 {
return it1._node != it2._node; }
439 explicit operator
bool() const noexcept {
return _node !=
nullptr; }
443 template <
typename U>
454 template <
typename T>
476 { _node = it._node;
return *
this; }
481 {
return it1._node == it2._node; }
483 {
return it1._node != it2._node; }
492 explicit operator
bool() const noexcept {
return _node !=
nullptr; }
496 template <
typename U>
Intrusive list constant iterator.
friend bool operator!=(const ListConstIterator &it1, const ListConstIterator &it2) noexcept
~ListConstIterator() noexcept=default
ListConstIterator & operator=(ListConstIterator &&it) noexcept=default
const value_type & const_reference
friend void swap(ListConstIterator< U > &it1, ListConstIterator< U > &it2) noexcept
const value_type * const_pointer
ListConstIterator(const ListIterator< T > &it) noexcept
ListConstIterator(const T *node) noexcept
ListConstIterator(const ListConstIterator &it) noexcept=default
std::bidirectional_iterator_tag iterator_category
ptrdiff_t difference_type
friend bool operator==(const ListConstIterator &it1, const ListConstIterator &it2) noexcept
ListConstIterator(ListConstIterator &&it) noexcept=default
ListConstIterator() noexcept
ListConstIterator & operator=(const ListConstIterator &it) noexcept=default
Intrusive list constant reverse iterator.
~ListConstReverseIterator() noexcept=default
ListConstReverseIterator(const ListConstReverseIterator &it) noexcept=default
const value_type * const_pointer
ListConstReverseIterator(ListConstReverseIterator &&it) noexcept=default
friend bool operator!=(const ListConstReverseIterator &it1, const ListConstReverseIterator &it2) noexcept
ptrdiff_t difference_type
ListConstReverseIterator & operator=(const ListConstReverseIterator &it) noexcept=default
ListConstReverseIterator() noexcept
friend bool operator==(const ListConstReverseIterator &it1, const ListConstReverseIterator &it2) noexcept
std::bidirectional_iterator_tag iterator_category
ListConstReverseIterator & operator=(ListConstReverseIterator &&it) noexcept=default
ListConstReverseIterator(const T *node) noexcept
friend void swap(ListConstReverseIterator< U > &it1, ListConstReverseIterator< U > &it2) noexcept
const value_type & const_reference
ListConstReverseIterator(const ListReverseIterator< T > &it) noexcept
Intrusive list container.
const_reverse_iterator crbegin() const noexcept
const value_type * const_pointer
ListReverseIterator< T > reverse_iterator
const_reverse_iterator crend() const noexcept
void push_next(T &base, T &item) noexcept
Push a new item as a next to the given one.
iterator end() noexcept
Get the end list iterator.
ptrdiff_t difference_type
const T * back() const noexcept
const T * front() const noexcept
size_t size() const noexcept
Get the list size.
T * front() noexcept
Get the front list item.
bool empty() const noexcept
Is the list empty?
void push_back(T &item) noexcept
Push a new item into the back of the list.
ListConstIterator< T > const_iterator
reverse_iterator rend() noexcept
Get the reverse end list iterator.
reverse_iterator rbegin() noexcept
Get the reverse begin list iterator.
ListConstReverseIterator< T > const_reverse_iterator
const_iterator cend() const noexcept
T * pop_back() noexcept
Pop the item from the back of the list.
List(const List &) noexcept=default
void push_prev(T &base, T &item) noexcept
Push a new item as a previous to the given one.
T * pop_front() noexcept
Pop the item from the front of the list.
ListIterator< T > iterator
void swap(List &list) noexcept
Swap two instances.
iterator begin() noexcept
Get the begin list iterator.
T * back() noexcept
Get the back list item.
const_iterator cbegin() const noexcept
T * pop_current(T &base) noexcept
Pop the given item from the list.
T * pop_prev(T &base) noexcept
Pop the previous item of the given one from the list.
void push_front(T &item) noexcept
Push a new item into the front of the list.
void clear() noexcept
Clear the list.
void reverse() noexcept
Reverse the list.
T * pop_next(T &base) noexcept
Pop the next item of the given one from the list.
List(List &&) noexcept=default
const value_type & const_reference
ptrdiff_t difference_type
friend bool operator!=(const ListIterator &it1, const ListIterator &it2) noexcept
const value_type * const_pointer
std::bidirectional_iterator_tag iterator_category
~ListIterator() noexcept=default
friend void swap(ListIterator< U > &it1, ListIterator< U > &it2) noexcept
const value_type & const_reference
ListIterator(const ListIterator &it) noexcept=default
ListIterator(ListIterator &&it) noexcept=default
ListIterator(T *node) noexcept
Intrusive list reverse iterator.
ListReverseIterator() noexcept
ListReverseIterator(T *node) noexcept
ptrdiff_t difference_type
ListReverseIterator(const ListReverseIterator &it) noexcept=default
const value_type & const_reference
friend void swap(ListReverseIterator< U > &it1, ListReverseIterator< U > &it2) noexcept
~ListReverseIterator() noexcept=default
ListReverseIterator(ListReverseIterator &&it) noexcept=default
const value_type * const_pointer
friend bool operator!=(const ListReverseIterator &it1, const ListReverseIterator &it2) noexcept
std::bidirectional_iterator_tag iterator_category
Intrusive list container inline implementation.
C++ Common project definitions.
T * prev
Pointer to the previous list node.
T * next
Pointer to the next list node.