|
libhatchet
|
#include <hxlist.hpp>
Classes | |
| class | const_iterator |
| class | iterator |
Public Types | |
| using | T = T |
Public Member Functions | |
| hxlist (deleter_t_ deleter_=deleter_t_()) | |
| ~hxlist (void) | |
| T & | back (void) |
| const T & | back (void) const |
| iterator | begin (void) |
| const_iterator | begin (void) const |
| const_iterator | cbegin (void) const |
| const_iterator | cend (void) const |
| template<typename deleter_u_> | |
| void | clear (deleter_u_ &&deleter_) noexcept |
| void | clear (void) |
| bool | empty (void) const |
| iterator | end (void) |
| const_iterator | end (void) const |
| template<typename deleter_u_> | |
| void | erase (const_iterator pos_, deleter_u_ &&deleter_) noexcept |
| void | erase (const_iterator pos_) noexcept |
| hxptr< T, deleter_t_ > | extract (const_iterator pos_) |
| template<typename callable_t_> | |
| const_iterator | find_if (callable_t_ &&callable_) const |
| template<typename callable_t_> | |
| iterator | find_if (callable_t_ &&callable_) |
| template<typename callable_t_> | |
| void | for_each (callable_t_ &&callable_) const |
| template<typename callable_t_> | |
| void | for_each (callable_t_ &&callable_) |
| const deleter_t_ & | deleter (void) const |
| deleter_t_ & | deleter (void) |
| T & | front (void) |
| const T & | front (void) const |
| template<typename deleter_u_> | |
| iterator | insert_after (const_iterator pos_, hxptr< T, deleter_u_ > &&ptr_) |
| iterator | insert_after (const_iterator pos_, T *ptr_) |
| template<typename deleter_u_> | |
| iterator | insert (const_iterator pos_, hxptr< T, deleter_u_ > &&ptr_) |
| iterator | insert (const_iterator pos_, T *ptr_) |
| hxptr< T, deleter_t_ > | pop_back (void) |
| hxptr< T, deleter_t_ > | pop_front (void) |
| template<typename deleter_u_> | |
| iterator | push_back (hxptr< T, deleter_u_ > &&ptr_) |
| iterator | push_back (T *ptr_) |
| template<typename deleter_u_> | |
| iterator | push_front (hxptr< T, deleter_u_ > &&ptr_) |
| iterator | push_front (T *ptr_) |
| void | release_all (void) |
| template<typename callable_t_, typename deleter_u_> | |
| hxsize_t | remove_if (callable_t_ &&callable_, deleter_u_ &&deleter_) noexcept |
| template<typename callable_t_> | |
| hxsize_t | remove_if (callable_t_ &&callable_) noexcept |
| void | reverse (void) |
| hxsize_t | size (void) const |
| void | splice (const_iterator pos_, hxlist &other_) |
hxlist - An intrusive doubly linked list that takes ownership of nodes via a deleter_t callable, defaulting to hxdefault_delete.
This is the same as hxconstexpr_list except that it does not work with constexpr as it uses pointer arithmetic to save one pointer per-node. T must derive from hxlist_node. The destructor calls clear() which invokes the deleter on all remaining nodes. Subclasses of T may be inserted heterogeneously. Use hxdo_not_delete to avoid freeing nodes. Note: It is possible to iterate backwards from --list.end() to --list.begin() however reverse iterators are not provided.
For example:
|
explicit |
Constructs an empty list with an optional deleter instance.
|
inline |
Destroys the list by calling clear(), which invokes the deleter on every remaining node.
| T & hxlist< T, deleter_t_ >::back | ( | void | ) |
Returns a reference to the last node. The list must not be empty.
| const T & hxlist< T, deleter_t_ >::back | ( | void | ) | const |
Returns a const reference to the last node. The list must not be empty.
| iterator hxlist< T, deleter_t_ >::begin | ( | void | ) |
Returns an iterator to the first node, or end() if the list is empty.
| const_iterator hxlist< T, deleter_t_ >::begin | ( | void | ) | const |
Returns a const iterator to the first node, or end() if the list is empty.
|
inline |
Returns a const iterator to the first node, or cend() if the list is empty.
|
inline |
Returns a const iterator to the sentinel, representing one past the last node.
|
inline |
Removes all nodes using the stored deleter.
| deleter_t_ & hxlist< T, deleter_t_ >::deleter | ( | void | ) |
Returns a reference to the stored deleter.
| const deleter_t_ & hxlist< T, deleter_t_ >::deleter | ( | void | ) | const |
Returns a const reference to the stored deleter.
|
inline |
Returns true if the list contains no nodes.
| iterator hxlist< T, deleter_t_ >::end | ( | void | ) |
Returns an iterator to the sentinel, representing one past the last node.
This is also the iterator to one before the first node.
| const_iterator hxlist< T, deleter_t_ >::end | ( | void | ) | const |
Returns a const iterator to the sentinel, representing one past the last node.
This is also the iterator to one before the first node.
|
noexcept |
Unlinks and deletes the node at pos using the stored deleter.
|
noexcept |
| iterator hxlist< T, deleter_t_ >::find_if | ( | callable_t_ && | callable_ | ) |
Non-const version of find_if.
| const_iterator hxlist< T, deleter_t_ >::find_if | ( | callable_t_ && | callable_ | ) | const |
| void hxlist< T, deleter_t_ >::for_each | ( | callable_t_ && | callable_ | ) |
Non-const version of for_each.
| void hxlist< T, deleter_t_ >::for_each | ( | callable_t_ && | callable_ | ) | const |
Calls a function, lambda, or std::function on each node.
| T & hxlist< T, deleter_t_ >::front | ( | void | ) |
Returns a reference to the first node. The list must not be empty.
| const T & hxlist< T, deleter_t_ >::front | ( | void | ) | const |
Returns a const reference to the first node. The list must not be empty.
| iterator hxlist< T, deleter_t_ >::insert_after | ( | const_iterator | pos_, |
| hxptr< T, deleter_u_ > && | ptr_ ) |
insert_after - Inserts the node owned by ptr immediately after pos.
Returns an iterator to the inserted node.
| iterator hxlist< T, deleter_t_ >::insert_after | ( | const_iterator | pos_, |
| T * | ptr_ ) |
insert_after - Inserts ptr immediately after pos.
Returns an iterator to the inserted node.
| iterator hxlist< T, deleter_t_ >::push_back | ( | T * | ptr_ | ) |
push_back - Inserts ptr at the back of the list.
Must not be null. Returns an iterator to the inserted node.
| iterator hxlist< T, deleter_t_ >::push_front | ( | hxptr< T, deleter_u_ > && | ptr_ | ) |
push_front - Inserts the node owned by ptr at the front of the list.
Returns an iterator to the inserted node.
| iterator hxlist< T, deleter_t_ >::push_front | ( | T * | ptr_ | ) |
push_front - Inserts ptr at the front of the list.
Must not be null. Returns an iterator to the inserted node.
| void hxlist< T, deleter_t_ >::release_all | ( | void | ) |
Resets the list to empty without invoking the deleter on any node.
Ownership of all nodes is abandoned. Use only when nodes are managed elsewhere or have already been freed.
|
noexcept |
Removes all nodes for which predicate returns true, invoking the stored deleter on each removed node.
Returns the number of nodes removed.
|
noexcept |
| void hxlist< T, deleter_t_ >::reverse | ( | void | ) |
Reverses the order of nodes in the list in-place.
WARNING: Iterators are invalidated.
|
inline |
Returns the number of nodes currently in the list.
| void hxlist< T, deleter_t_ >::splice | ( | const_iterator | pos_, |
| hxlist< T, deleter_t_ > & | other_ ) |
Transfers all nodes from other and inserts them before pos, taking ownership.
other is left empty after the call.