A doubly-linked intrusive list.
IntrusiveList<T> is a handle to access and manipulate the list, and IntrusiveList<T>::Item is the type from which the base class items must derive.
As a doubly-linked list, operations such as removal are O(1) in time, and the list may be iterated in either direction. However, the overhead needed is 2*sizeof(T*).
This class is modeled on std::list, with the following differences:
iterators and not const_iterators:erase is provided that takes a direct reference to an item.| T | Type of intrusive items stored in the list. |
Classes | |
| class | Item |
Public Member Functions | |
| IntrusiveList (const IntrusiveList &)=delete | |
| IntrusiveList & | operator= (const IntrusiveList &)=delete |
| IntrusiveList (IntrusiveList &&)=default | |
| IntrusiveList & | operator= (IntrusiveList &&)=default |
| template<typename Iterator > | |
| IntrusiveList (Iterator first, Iterator last) | |
| IntrusiveList (std::initializer_list< Item * > items) | |
| template<typename Iterator > | |
| void | assign (Iterator first, Iterator last) |
| void | assign (std::initializer_list< T * > items) |
| T & | front () |
| Reference to the first element in the list. Undefined behavior if empty(). | |
| T & | back () |
| Reference to the last element in the list. Undefined behavior if empty(). | |
| iterator | begin () noexcept |
| const_iterator | begin () const noexcept |
| const_iterator | cbegin () const noexcept |
| iterator | end () noexcept |
| const_iterator | end () const noexcept |
| const_iterator | cend () const noexcept |
| reverse_iterator | rbegin () |
| const_reverse_iterator | rbegin () const |
| const_reverse_iterator | crbegin () const |
| reverse_iterator | rend () |
| const_reverse_iterator | rend () const |
| const_reverse_iterator | crend () const |
| bool | empty () const noexcept |
| size_t | size () const |
| constexpr size_type | max_size () const noexcept |
| void | clear () |
| Removes all items from the list. | |
| iterator | insert (iterator pos, T &item) |
Inserts the given item before the given position, pos. | |
| template<typename Iterator > | |
| iterator | insert (iterator pos, Iterator first, Iterator last) |
| iterator | insert (iterator pos, std::initializer_list< T * > items) |
| iterator | erase (T &item) |
Removes the given item from the list. The item is not destructed. | |
| iterator | erase (iterator pos) |
| iterator | erase (iterator first, iterator last) |
Removes the range of items from first (inclusive) to last (exclusive). | |
| void | push_back (T &item) |
| Inserts an element at the end of the list. | |
| void | pop_back () |
| Removes the last item in the list. The list must not be empty. | |
| void | push_front (T &item) |
| Inserts an element at the beginning of the list. | |
| void | pop_front () |
| Removes the first item in the list. The list must not be empty. | |
| void | swap (IntrusiveList< T > &other) noexcept |
| void | merge (IntrusiveList< T > &other) |
| template<typename Compare > | |
| void | merge (IntrusiveList< T > &other, Compare comp) |
| void | splice (iterator pos, IntrusiveList< T > &other) |
| void | splice (iterator pos, IntrusiveList< T > &other, iterator it) |
| void | splice (iterator pos, IntrusiveList< T > &other, iterator first, iterator last) |
| bool | remove (const T &item) |
| template<typename UnaryPredicate > | |
| size_type | remove_if (UnaryPredicate pred) |
| void | reverse () |
| Reverses the order of items in the list. | |
| size_type | unique () |
| template<typename BinaryPredicate > | |
| size_type | unique (BinaryPredicate pred) |
| void | sort () |
| template<typename Compare > | |
| void | sort (Compare comp) |