libhatchet
Loading...
Searching...
No Matches
hxconstexpr_list< T, deleter_t_ > Class Template Reference

#include <hxconstexpr_list.hpp>

Classes

class  const_iterator
class  iterator

Public Types

using node_t = T

Public Member Functions

constexpr hxconstexpr_list (deleter_t_ deleter_=deleter_t_())
constexpr ~hxconstexpr_list (void)
constexpr T & back (void)
constexpr const T & back (void) const
constexpr iterator begin (void)
constexpr const_iterator begin (void) const
constexpr const_iterator cbegin (void) const
constexpr const_iterator cend (void) const
template<typename deleter_u_>
constexpr void clear (deleter_u_ &&deleter_) noexcept
constexpr void clear (void)
constexpr bool empty (void) const
constexpr iterator end (void)
constexpr const_iterator end (void) const
template<typename deleter_u_>
constexpr void erase (const_iterator pos_, deleter_u_ &&deleter_) noexcept
constexpr void erase (const_iterator pos_) noexcept
constexpr hxptr< T, deleter_t_ > extract (const_iterator pos_)
template<typename callable_t_>
constexpr const_iterator find_if (callable_t_ &&callable_) const
template<typename callable_t_>
constexpr iterator find_if (callable_t_ &&callable_)
template<typename callable_t_>
constexpr void for_each (callable_t_ &&callable_) const
template<typename callable_t_>
constexpr void for_each (callable_t_ &&callable_)
constexpr const deleter_t_ & deleter (void) const
constexpr deleter_t_ & deleter (void)
constexpr T & front (void)
constexpr const T & front (void) const
template<typename deleter_u_>
constexpr iterator insert_after (const_iterator pos_, hxptr< T, deleter_u_ > &&ptr_)
constexpr iterator insert_after (const_iterator pos_, T *ptr_)
template<typename deleter_u_>
constexpr iterator insert (const_iterator pos_, hxptr< T, deleter_u_ > &&ptr_)
constexpr iterator insert (const_iterator pos_, T *ptr_)
constexpr hxptr< T, deleter_t_ > pop_back (void)
constexpr hxptr< T, deleter_t_ > pop_front (void)
template<typename deleter_u_>
constexpr iterator push_back (hxptr< T, deleter_u_ > &&ptr_)
constexpr iterator push_back (T *ptr_)
template<typename deleter_u_>
constexpr iterator push_front (hxptr< T, deleter_u_ > &&ptr_)
constexpr iterator push_front (T *ptr_)
constexpr void release_all (void)
template<typename callable_t_, typename deleter_u_>
constexpr hxsize_t remove_if (callable_t_ &&callable_, deleter_u_ &&deleter_) noexcept
template<typename callable_t_>
constexpr hxsize_t remove_if (callable_t_ &&callable_) noexcept
constexpr void reverse (void)
constexpr hxsize_t size (void) const
constexpr void splice (const_iterator pos_, hxconstexpr_list &other_)

Detailed Description

template<typename T, typename deleter_t_ = hxdefault_delete>
class hxconstexpr_list< T, deleter_t_ >

hxconstexpr_list - An intrusive doubly linked list that takes ownership of nodes via a deleter_t callable, defaulting to hxdefault_delete.

T must derive from hxconstexpr_list_node. The destructor calls clear() which invokes the deleter on all remaining nodes. Subclasses of T may be inserted heterogeneously. Note: It is possible to iterate backwards from --list.end() to --list.begin() however reverse iterators are not provided.

For example:

struct example_t : public hxconstexpr_list_node {
example_t(int x) : value(x) { }
int value;
};
for(example_t& n : list) {
::printf("%d\n", n.value);
}
hxconstexpr_list_node - Intrusive doubly linked list node base.
Definition hxconstexpr_list.hpp:31
constexpr hxconstexpr_list(deleter_t_ deleter_=deleter_t_())
Constructs an empty list with an optional deleter instance.
constexpr iterator push_back(hxptr< T, deleter_u_ > &&ptr_)
push_back - Inserts the node owned by ptr at the back of the list.
T * hxnew(Args_ &&... args_) noexcept
hxnew<T, allocator, align>(...) - Allocates and constructs an object of type T using an optional memo...
Definition hxmemory_manager.h:235

Member Typedef Documentation

◆ node_t

template<typename T, typename deleter_t_ = hxdefault_delete>
using hxconstexpr_list< T, deleter_t_ >::node_t = T

T - The node type stored in the list.

Derives from hxconstexpr_list_node.

Constructor & Destructor Documentation

◆ hxconstexpr_list()

template<typename T, typename deleter_t_ = hxdefault_delete>
hxconstexpr_list< T, deleter_t_ >::hxconstexpr_list ( deleter_t_ deleter_ = deleter_t_())
explicitconstexpr

Constructs an empty list with an optional deleter instance.

  • deleter : Callable with signature bool deleter(T*).

◆ ~hxconstexpr_list()

template<typename T, typename deleter_t_ = hxdefault_delete>
hxconstexpr_list< T, deleter_t_ >::~hxconstexpr_list ( void )
inlineconstexpr

Destroys the list by calling clear(), which invokes the deleter on every remaining node.

Member Function Documentation

◆ back() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
T & hxconstexpr_list< T, deleter_t_ >::back ( void )
constexpr

Returns a reference to the last node. The list must not be empty.

◆ back() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
const T & hxconstexpr_list< T, deleter_t_ >::back ( void ) const
constexpr

Returns a const reference to the last node. The list must not be empty.

◆ begin() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
iterator hxconstexpr_list< T, deleter_t_ >::begin ( void )
inlineconstexpr

Returns an iterator to the first node, or end() if the list is empty.

◆ begin() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
const_iterator hxconstexpr_list< T, deleter_t_ >::begin ( void ) const
constexpr

Returns a const iterator to the first node, or end() if the list is empty.

◆ cbegin()

template<typename T, typename deleter_t_ = hxdefault_delete>
const_iterator hxconstexpr_list< T, deleter_t_ >::cbegin ( void ) const
inlineconstexpr

Returns a const iterator to the first node, or cend() if the list is empty.

◆ cend()

template<typename T, typename deleter_t_ = hxdefault_delete>
const_iterator hxconstexpr_list< T, deleter_t_ >::cend ( void ) const
inlineconstexpr

Returns a const iterator to the sentinel, representing one past the last node.

◆ clear() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
template<typename deleter_u_>
void hxconstexpr_list< T, deleter_t_ >::clear ( deleter_u_ && deleter_)
constexprnoexcept

Removes all nodes, invoking deleter on each.

If deleter evaluates to false nodes are unlinked but not freed.

  • deleter : Callable with signature bool deleter(T*).

◆ clear() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
void hxconstexpr_list< T, deleter_t_ >::clear ( void )
inlineconstexpr

Removes all nodes using the stored deleter.

◆ deleter() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
deleter_t_ & hxconstexpr_list< T, deleter_t_ >::deleter ( void )
constexpr

Returns a reference to the stored deleter.

◆ deleter() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
const deleter_t_ & hxconstexpr_list< T, deleter_t_ >::deleter ( void ) const
constexpr

Returns a const reference to the stored deleter.

◆ empty()

template<typename T, typename deleter_t_ = hxdefault_delete>
bool hxconstexpr_list< T, deleter_t_ >::empty ( void ) const
constexpr

Returns true if the list contains no nodes.

◆ end() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
iterator hxconstexpr_list< T, deleter_t_ >::end ( void )
inlineconstexpr

Returns an iterator to the sentinel, representing one past the last node.

This is also the iterator to one before the first node.

◆ end() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
const_iterator hxconstexpr_list< T, deleter_t_ >::end ( void ) const
constexpr

Returns a const iterator to the sentinel, representing one past the last node.

This is also the iterator to one before the first node.

◆ erase() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
void hxconstexpr_list< T, deleter_t_ >::erase ( const_iterator pos_)
constexprnoexcept

Unlinks and deletes the node at pos if deleter is true then calls deleter on it.

  • pos : Iterator to the node to unlink and delete.

◆ erase() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
template<typename deleter_u_>
void hxconstexpr_list< T, deleter_t_ >::erase ( const_iterator pos_,
deleter_u_ && deleter_ )
constexprnoexcept

Unlinks the node at pos and if deleter is true then calls deleter on it.

  • pos : The node to unlink and erase.
  • deleter : Callable with signature bool deleter(T*).

◆ extract()

template<typename T, typename deleter_t_ = hxdefault_delete>
hxptr< T, deleter_t_ > hxconstexpr_list< T, deleter_t_ >::extract ( const_iterator pos_)
constexpr

extract - Returns an hxptr owning the node at pos after unlinking it from the list.

  • pos : Iterator to the node to unlink and return.

◆ find_if() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
template<typename callable_t_>
iterator hxconstexpr_list< T, deleter_t_ >::find_if ( callable_t_ && callable_)
constexpr

Non-const version of find_if.

◆ find_if() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
template<typename callable_t_>
const_iterator hxconstexpr_list< T, deleter_t_ >::find_if ( callable_t_ && callable_) const
constexpr

Finds the first node for which the predicate returns true.

Returns end() if no node matches.

  • callable : A callable taking a T reference, returning bool.

◆ for_each() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
template<typename callable_t_>
void hxconstexpr_list< T, deleter_t_ >::for_each ( callable_t_ && callable_)
constexpr

Non-const version of for_each.

◆ for_each() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
template<typename callable_t_>
void hxconstexpr_list< T, deleter_t_ >::for_each ( callable_t_ && callable_) const
constexpr

Calls a function, lambda, or std::function on each node.

  • callable : A callable taking a T reference.

◆ front() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
T & hxconstexpr_list< T, deleter_t_ >::front ( void )
constexpr

Returns a reference to the first node. The list must not be empty.

◆ front() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
const T & hxconstexpr_list< T, deleter_t_ >::front ( void ) const
constexpr

Returns a const reference to the first node. The list must not be empty.

◆ insert() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
template<typename deleter_u_>
iterator hxconstexpr_list< T, deleter_t_ >::insert ( const_iterator pos_,
hxptr< T, deleter_u_ > && ptr_ )
constexpr

insert - Inserts the node owned by ptr immediately before pos.

Returns an iterator to the inserted node.

  • pos : Iterator to the node before which ptr is inserted. May be end().
  • ptr : The hxptr owning the node to insert.

◆ insert() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
iterator hxconstexpr_list< T, deleter_t_ >::insert ( const_iterator pos_,
T * ptr_ )
constexpr

insert - Inserts ptr immediately before pos.

May be end(). Returns an iterator to the inserted node.

  • pos : Iterator to the node before which ptr is inserted.
  • ptr : The node to insert. Must not be null.

◆ insert_after() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
template<typename deleter_u_>
iterator hxconstexpr_list< T, deleter_t_ >::insert_after ( const_iterator pos_,
hxptr< T, deleter_u_ > && ptr_ )
constexpr

insert_after - Inserts the node owned by ptr immediately after pos.

Returns an iterator to the inserted node.

  • pos : Iterator to the node after which ptr is inserted.
  • ptr : The hxptr owning the node to insert.

◆ insert_after() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
iterator hxconstexpr_list< T, deleter_t_ >::insert_after ( const_iterator pos_,
T * ptr_ )
constexpr

insert_after - Inserts ptr immediately after pos.

Returns an iterator to the inserted node.

  • pos : Iterator to the node after which ptr is inserted.
  • ptr : The node to insert. Must not be null.

◆ pop_back()

template<typename T, typename deleter_t_ = hxdefault_delete>
hxptr< T, deleter_t_ > hxconstexpr_list< T, deleter_t_ >::pop_back ( void )
constexpr

pop_back - Returns an hxptr owning the last node.

The list must not be empty.

◆ pop_front()

template<typename T, typename deleter_t_ = hxdefault_delete>
hxptr< T, deleter_t_ > hxconstexpr_list< T, deleter_t_ >::pop_front ( void )
constexpr

pop_front - Returns an hxptr owning the first node.

The list must not be empty.

◆ push_back() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
template<typename deleter_u_>
iterator hxconstexpr_list< T, deleter_t_ >::push_back ( hxptr< T, deleter_u_ > && ptr_)
constexpr

push_back - Inserts the node owned by ptr at the back of the list.

Returns an iterator to the inserted node.

  • ptr : The hxptr owning the node to append. Must not be null.

◆ push_back() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
iterator hxconstexpr_list< T, deleter_t_ >::push_back ( T * ptr_)
constexpr

push_back - Inserts ptr at the back of the list.

Must not be null. Returns an iterator to the inserted node.

  • ptr : The node to append.

◆ push_front() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
template<typename deleter_u_>
iterator hxconstexpr_list< T, deleter_t_ >::push_front ( hxptr< T, deleter_u_ > && ptr_)
constexpr

push_front - Inserts the node owned by ptr at the front of the list.

Returns an iterator to the inserted node.

  • ptr : The hxptr owning the node to prepend. Must not be null.

◆ push_front() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
iterator hxconstexpr_list< T, deleter_t_ >::push_front ( T * ptr_)
constexpr

push_front - Inserts ptr at the front of the list.

Must not be null. Returns an iterator to the inserted node.

  • ptr : The node to prepend.

◆ release_all()

template<typename T, typename deleter_t_ = hxdefault_delete>
void hxconstexpr_list< T, deleter_t_ >::release_all ( void )
constexpr

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.

◆ remove_if() [1/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
template<typename callable_t_>
hxsize_t hxconstexpr_list< T, deleter_t_ >::remove_if ( callable_t_ && callable_)
constexprnoexcept

Removes all nodes for which predicate returns true, invoking the stored deleter on each removed node.

Returns the number of nodes removed.

  • callable : A callable taking a T reference, returning bool.

◆ remove_if() [2/2]

template<typename T, typename deleter_t_ = hxdefault_delete>
template<typename callable_t_, typename deleter_u_>
hxsize_t hxconstexpr_list< T, deleter_t_ >::remove_if ( callable_t_ && callable_,
deleter_u_ && deleter_ )
constexprnoexcept

Removes all nodes for which predicate returns true, invoking deleter on each removed node.

If deleter evaluates to false nodes are unlinked but not freed. Returns the number of nodes removed.

  • callable : A callable taking a T reference, returning bool.
  • deleter : Callable with signature bool deleter(T*).

◆ reverse()

template<typename T, typename deleter_t_ = hxdefault_delete>
void hxconstexpr_list< T, deleter_t_ >::reverse ( void )
constexpr

Reverses the order of nodes in the list in-place.

◆ size()

template<typename T, typename deleter_t_ = hxdefault_delete>
hxsize_t hxconstexpr_list< T, deleter_t_ >::size ( void ) const
inlineconstexpr

Returns the number of nodes currently in the list.

◆ splice()

template<typename T, typename deleter_t_ = hxdefault_delete>
void hxconstexpr_list< T, deleter_t_ >::splice ( const_iterator pos_,
hxconstexpr_list< T, deleter_t_ > & other_ )
constexpr

Transfers all nodes from other and inserts them before pos, taking ownership.

other is left empty after the call.

  • pos : Iterator before which nodes are inserted.
  • other : The list to splice from. Left empty after the call.

The documentation for this class was generated from the following file: