distortos  v0.4.0
object-oriented C++ RTOS for microcontrollers
estd::SortedIntrusiveList< Compare, T, NodePointer, U > Class Template Reference

SortedIntrusiveList class is an IntrusiveList with sorted elements. More...

#include <SortedIntrusiveList.hpp>

Collaboration diagram for estd::SortedIntrusiveList< Compare, T, NodePointer, U >:
[legend]

Classes

struct  Implementation
 Implementation struct is used primarily for "Empty Base Optimization" with Compare type. More...
 

Public Types

using UnsortedIntrusiveList = IntrusiveList< T, NodePointer, U >
 unsorted intrusive list used internally More...
 
using const_iterator = typename UnsortedIntrusiveList::const_iterator
 const iterator of elements on the list More...
 
using const_reverse_iterator = typename UnsortedIntrusiveList::const_reverse_iterator
 const reverse iterator of elements on the list More...
 
using const_pointer = typename UnsortedIntrusiveList::const_pointer
 const pointer to value linked in the list More...
 
using const_reference = typename UnsortedIntrusiveList::const_reference
 const reference to value linked in the list More...
 
using iterator = typename UnsortedIntrusiveList::iterator
 iterator of elements on the list More...
 
using reverse_iterator = typename UnsortedIntrusiveList::reverse_iterator
 reverse iterator of elements on the list More...
 
using pointer = typename UnsortedIntrusiveList::pointer
 pointer to value linked in the list More...
 
using reference = typename UnsortedIntrusiveList::reference
 reference to value linked in the list More...
 
using value_type = typename UnsortedIntrusiveList::value_type
 value linked in the list More...
 

Public Member Functions

constexpr SortedIntrusiveList (const Compare &compare=Compare{})
 SortedIntrusiveList's constructor. More...
 
reference back ()
 
const_reference back () const
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
void clear ()
 Unlinks all elements from the list. More...
 
bool empty () const
 
iterator end ()
 
const_iterator end () const
 
reference front ()
 
const_reference front () const
 
iterator insert (reference newElement)
 Links the element in the list, keeping it sorted. More...
 
void pop_back ()
 Unlinks the last element from the list. More...
 
void pop_front ()
 Unlinks the first element from the list. More...
 
void splice (const iterator splicedElement)
 Transfers the element from another list to this one, keeping it sorted. More...
 
void swap (SortedIntrusiveList &other)
 Swaps contents with another list. More...
 
 SortedIntrusiveList (const SortedIntrusiveList &)=delete
 
 SortedIntrusiveList (SortedIntrusiveList &&)=default
 
const SortedIntrusiveListoperator= (const SortedIntrusiveList &)=delete
 
SortedIntrusiveListoperator= (SortedIntrusiveList &&)=delete
 

Static Public Member Functions

static iterator erase (const iterator position)
 Unlinks the element at position from the list. More...
 

Private Attributes

Implementation implementation_
 internal Implementation object - unsorted IntrusiveList and Compare instance More...
 

Detailed Description

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
class estd::SortedIntrusiveList< Compare, T, NodePointer, U >

SortedIntrusiveList class is an IntrusiveList with sorted elements.

This class tries to provide an interface similar to std::list.

Note
The elements are sorted as long as the user does not modify the contents.
Template Parameters
Compareis a type of functor used for comparison, std::less results in descending order, std::greater - in ascending order
Tis the type that has the IntrusiveListNode variable
NodePointeris a pointer-to-member to IntrusiveListNode variable in T
Uis the type that will be stored on the list; it can be different from T, but must be implicitly convertible to T (so usually a type derived from T); default - T; using different type than T can be used to break circular dependencies, because T must be fully defined to instantiate this class, but it is enough to forward declare U - it only needs to be fully defined to use member functions

Member Typedef Documentation

◆ const_iterator

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
using estd::SortedIntrusiveList< Compare, T, NodePointer, U >::const_iterator = typename UnsortedIntrusiveList::const_iterator

const iterator of elements on the list

◆ const_pointer

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
using estd::SortedIntrusiveList< Compare, T, NodePointer, U >::const_pointer = typename UnsortedIntrusiveList::const_pointer

const pointer to value linked in the list

◆ const_reference

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
using estd::SortedIntrusiveList< Compare, T, NodePointer, U >::const_reference = typename UnsortedIntrusiveList::const_reference

const reference to value linked in the list

◆ const_reverse_iterator

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
using estd::SortedIntrusiveList< Compare, T, NodePointer, U >::const_reverse_iterator = typename UnsortedIntrusiveList::const_reverse_iterator

const reverse iterator of elements on the list

◆ iterator

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
using estd::SortedIntrusiveList< Compare, T, NodePointer, U >::iterator = typename UnsortedIntrusiveList::iterator

iterator of elements on the list

◆ pointer

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
using estd::SortedIntrusiveList< Compare, T, NodePointer, U >::pointer = typename UnsortedIntrusiveList::pointer

pointer to value linked in the list

◆ reference

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
using estd::SortedIntrusiveList< Compare, T, NodePointer, U >::reference = typename UnsortedIntrusiveList::reference

reference to value linked in the list

◆ reverse_iterator

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
using estd::SortedIntrusiveList< Compare, T, NodePointer, U >::reverse_iterator = typename UnsortedIntrusiveList::reverse_iterator

reverse iterator of elements on the list

◆ UnsortedIntrusiveList

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
using estd::SortedIntrusiveList< Compare, T, NodePointer, U >::UnsortedIntrusiveList = IntrusiveList<T, NodePointer, U>

unsorted intrusive list used internally

◆ value_type

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
using estd::SortedIntrusiveList< Compare, T, NodePointer, U >::value_type = typename UnsortedIntrusiveList::value_type

value linked in the list

Constructor & Destructor Documentation

◆ SortedIntrusiveList()

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
constexpr estd::SortedIntrusiveList< Compare, T, NodePointer, U >::SortedIntrusiveList ( const Compare &  compare = Compare{})
inline

SortedIntrusiveList's constructor.

Parameters
[in]compareis a reference to Compare object used to copy-construct internal comparison functor
Here is the caller graph for this function:

Member Function Documentation

◆ back() [1/2]

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
reference estd::SortedIntrusiveList< Compare, T, NodePointer, U >::back ( )
inline
Returns
reference to last element on the list

◆ back() [2/2]

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
const_reference estd::SortedIntrusiveList< Compare, T, NodePointer, U >::back ( ) const
inline
Returns
const reference to last element on the list

◆ begin() [1/2]

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
iterator estd::SortedIntrusiveList< Compare, T, NodePointer, U >::begin ( )
inline
Returns
iterator of first element on the list
Here is the caller graph for this function:

◆ begin() [2/2]

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
const_iterator estd::SortedIntrusiveList< Compare, T, NodePointer, U >::begin ( ) const
inline
Returns
const iterator of first element on the list

◆ cbegin()

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
const_iterator estd::SortedIntrusiveList< Compare, T, NodePointer, U >::cbegin ( ) const
inline
Returns
const iterator of first element on the list

◆ cend()

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
const_iterator estd::SortedIntrusiveList< Compare, T, NodePointer, U >::cend ( ) const
inline
Returns
const iterator of "one past the last" element on the list

◆ clear()

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
void estd::SortedIntrusiveList< Compare, T, NodePointer, U >::clear ( )
inline

Unlinks all elements from the list.

◆ empty()

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
bool estd::SortedIntrusiveList< Compare, T, NodePointer, U >::empty ( ) const
inline
Returns
true is the list is empty, false otherwise
Here is the caller graph for this function:

◆ end() [1/2]

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
iterator estd::SortedIntrusiveList< Compare, T, NodePointer, U >::end ( )
inline
Returns
iterator of "one past the last" element on the list
Here is the caller graph for this function:

◆ end() [2/2]

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
const_iterator estd::SortedIntrusiveList< Compare, T, NodePointer, U >::end ( ) const
inline
Returns
const iterator of "one past the last" element on the list

◆ erase()

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
static iterator estd::SortedIntrusiveList< Compare, T, NodePointer, U >::erase ( const iterator  position)
inlinestatic

Unlinks the element at position from the list.

Note
No instance of the list is needed for this operation.
Parameters
[in]positionis an iterator of the element that will be unlinked from the list
Returns
iterator of the element that was following the element which was unlinked

◆ front() [1/2]

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
reference estd::SortedIntrusiveList< Compare, T, NodePointer, U >::front ( )
inline
Returns
reference to first element on the list

◆ front() [2/2]

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
const_reference estd::SortedIntrusiveList< Compare, T, NodePointer, U >::front ( ) const
inline
Returns
const reference to first element on the list

◆ insert()

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
iterator estd::SortedIntrusiveList< Compare, T, NodePointer, U >::insert ( reference  newElement)
inline

Links the element in the list, keeping it sorted.

Parameters
[in]newElementis a reference to the element that will be linked in the list
Returns
iterator of newElement
Here is the caller graph for this function:

◆ pop_back()

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
void estd::SortedIntrusiveList< Compare, T, NodePointer, U >::pop_back ( )
inline

Unlinks the last element from the list.

◆ pop_front()

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
void estd::SortedIntrusiveList< Compare, T, NodePointer, U >::pop_front ( )
inline

Unlinks the first element from the list.

◆ splice()

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
void estd::SortedIntrusiveList< Compare, T, NodePointer, U >::splice ( const iterator  splicedElement)
inline

Transfers the element from another list to this one, keeping it sorted.

Parameters
[in]splicedElementis an iterator of the element that will be spliced from another list to this one
Here is the caller graph for this function:

◆ swap()

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
void estd::SortedIntrusiveList< Compare, T, NodePointer, U >::swap ( SortedIntrusiveList< Compare, T, NodePointer, U > &  other)
inline

Swaps contents with another list.

Parameters
[in]otheris a reference to SortedIntrusiveList with which contents of this list will be swapped
Here is the caller graph for this function:

Member Data Documentation

◆ implementation_

template<typename Compare, typename T, IntrusiveListNode T::* NodePointer, typename U = T>
Implementation estd::SortedIntrusiveList< Compare, T, NodePointer, U >::implementation_
private

internal Implementation object - unsorted IntrusiveList and Compare instance


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