iceoryx_hoofs 2.0.3
Classes | Public Types | Public Member Functions | List of all members
iox::cxx::list< T, Capacity > Class Template Reference

C++11 compatible bi-directional list implementation. More...

#include <iceoryx_hoofs/cxx/list.hpp>

Public Types

using iterator = IteratorBase< false >
 
using const_iterator = IteratorBase< true >
 
using value_type = T
 
using size_type = decltype(Capacity)
 

Public Member Functions

 list () noexcept
 constructor for an empty list (of T-types elements)
 
 ~list () noexcept
 destructs the list and also calls the destructor of all contained elements
 
 list (const list &rhs) noexcept
 copy constructor list including elements More...
 
 list (list &&rhs) noexcept
 move constructor list including elements More...
 
listoperator= (const list &rhs) noexcept
 copy assignment, each element is copied (added) to the constructed list any existing elements in 'this'/lhs are removed (same behaviour as std::list : Assigns new contents to the container, replacing its current contents, and modifying its size accordingly.) More...
 
listoperator= (list &&rhs) noexcept
 move assignment, list is cleared and initialized, elements are moved from source list any existing elements in 'this'/lhs are removed (same behaviour as std::list : Assigns new contents to the container, replacing its current contents, and modifying its size accordingly.) More...
 
iterator begin () noexcept
 default list operation to retrieve an interator to first list element More...
 
const_iterator begin () const noexcept
 default list operation to retrieve an const_iterator to first list element More...
 
const_iterator cbegin () const noexcept
 default list operation to retrieve an const_iterator to first list element More...
 
iterator end () noexcept
 default list operation to retrieve an interator to end of list (behind last valid element) Terminated when content is attemted to read (operator*, operator->) More...
 
const_iterator end () const noexcept
 default list operation to retrieve an const_iterator to end of list (behind last valid element) Terminated when content is attemted to read (operator*, operator->) More...
 
const_iterator cend () const noexcept
 default list operation to retrieve an const_iterator to end of list (behind last valid element) Terminated when content is attemted to read (operator*, operator->) More...
 
bool empty () const noexcept
 list meta information on filling More...
 
bool full () const noexcept
 list meta information on filling More...
 
size_type size () const noexcept
 list meta information on filling More...
 
size_type capacity () const noexcept
 list meta information, maximum number of elements the list can contain More...
 
size_type max_size () const noexcept
 list meta information, maximum number of elements the list can contain More...
 
T & front () noexcept
 Returns a reference to the first element in the container. calling front() on an empty list will terminate() the processing. More...
 
const T & front () const noexcept
 Returns a reference to the first element in the container. calling front() on an empty list will terminate() the processing. More...
 
T & back () noexcept
 Returns a reference to the last element in the container. calling back() on an empty list will terminate() the processing. More...
 
const T & back () const noexcept
 Returns a reference to the last element in the container. calling back() on an empty list will terminate() the processing. More...
 
bool push_front (const T &data) noexcept
 add element to the beginning of the list More...
 
bool push_front (T &&data) noexcept
 add element to the beginning of the list via move More...
 
bool push_back (const T &data) noexcept
 add element to the end of the list More...
 
bool push_back (T &&data) noexcept
 add element to the end of the list via move More...
 
bool pop_front () noexcept
 remove the first element from the begining of the list element destructor will be invoked More...
 
bool pop_back () noexcept
 remove the last element from the end of the list element destructor will be invoked More...
 
void clear () noexcept
 remove all elements from the list, list will be empty element destructors will be invoked
 
iterator erase (const_iterator iter) noexcept
 remove next element from linked iterator position element destructors will be invoked recursive calls to erase_after only delete each 2nd element More...
 
size_type remove (const T &data) noexcept
 remove all elements which matches the given comparing element (compare by value) requires a the template type T to have operator== defined. More...
 
template<typename UnaryPredicate >
size_type remove_if (UnaryPredicate pred) noexcept
 remove all elements which matches the provided comparison function requires a the template type T to have a operator== defined. More...
 
template<typename... ConstructorArgs>
T & emplace_front (ConstructorArgs &&... args) noexcept
 construct element inplace at begining of list More...
 
template<typename... ConstructorArgs>
T & emplace_back (ConstructorArgs &&... args) noexcept
 construct element inplace at end of list More...
 
template<typename... ConstructorArgs>
iterator emplace (const_iterator iter, ConstructorArgs &&... args) noexcept
 construct element inplace at iterator position More...
 
iterator insert (const_iterator citer, const T &data) noexcept
 insert element before iterator position More...
 
iterator insert (const_iterator citer, T &&data) noexcept
 add element before the pointed-to element via move More...
 

Detailed Description

template<typename T, uint64_t Capacity>
class iox::cxx::list< T, Capacity >

C++11 compatible bi-directional list implementation.

Adjustments in the API were done to not use exceptions and serve the requirement of a data structure movable over shared memory. attempt to add elements to a full list will be ignored. Capacity must at least be 1, (unintended) negative initialization is rejected with compile assertion limitation: concurrency concerns have to be handled by client side.

overview of cxx::forward_list deviations to std::forward_list(C++11)

(yet) missing implementations

Parameters
Ttype user data to be managed within list
Capacitynumber of maximum list elements a client can push to the list. minimum value is '1'

Constructor & Destructor Documentation

◆ list() [1/2]

template<typename T , uint64_t Capacity>
iox::cxx::list< T, Capacity >::list ( const list< T, Capacity > &  rhs)
noexcept

copy constructor list including elements

Parameters
[in]rhsis the list to copy from (same capacity)

◆ list() [2/2]

template<typename T , uint64_t Capacity>
iox::cxx::list< T, Capacity >::list ( list< T, Capacity > &&  rhs)
noexcept

move constructor list including elements

Parameters
[in]rhsis the list to move-construct elements from (same capacity)

Member Function Documentation

◆ back() [1/2]

template<typename T , uint64_t Capacity>
const T & iox::cxx::list< T, Capacity >::back ( ) const
noexcept

Returns a reference to the last element in the container. calling back() on an empty list will terminate() the processing.

Returns
const reference to the last element

◆ back() [2/2]

template<typename T , uint64_t Capacity>
T & iox::cxx::list< T, Capacity >::back ( )
noexcept

Returns a reference to the last element in the container. calling back() on an empty list will terminate() the processing.

Returns
reference to the last element

◆ begin() [1/2]

template<typename T , uint64_t Capacity>
const_iterator iox::cxx::list< T, Capacity >::begin ( ) const
noexcept

default list operation to retrieve an const_iterator to first list element

Returns
iterator to first list element, returns iterator to end() when list is empty

◆ begin() [2/2]

template<typename T , uint64_t Capacity>
iterator iox::cxx::list< T, Capacity >::begin ( )
noexcept

default list operation to retrieve an interator to first list element

Returns
iterator to first list element, returns iterator to end() when list is empty

◆ capacity()

template<typename T , uint64_t Capacity>
size_type iox::cxx::list< T, Capacity >::capacity ( ) const
noexcept

list meta information, maximum number of elements the list can contain

Returns
list has been initialized with the following number of elements.

◆ cbegin()

template<typename T , uint64_t Capacity>
const_iterator iox::cxx::list< T, Capacity >::cbegin ( ) const
noexcept

default list operation to retrieve an const_iterator to first list element

Returns
iterator to first list element, returns iterator to end() when list is empty

◆ cend()

template<typename T , uint64_t Capacity>
const_iterator iox::cxx::list< T, Capacity >::cend ( ) const
noexcept

default list operation to retrieve an const_iterator to end of list (behind last valid element) Terminated when content is attemted to read (operator*, operator->)

Returns
iterator to end element, does not contain data.

◆ emplace()

template<typename T , uint64_t Capacity>
template<typename... ConstructorArgs>
iterator iox::cxx::list< T, Capacity >::emplace ( const_iterator  iter,
ConstructorArgs &&...  args 
)
noexcept

construct element inplace at iterator position

Parameters
[in]argsT-typed construction parameters (initializer list)
[in]iterposition in list to (construct)insert after
Returns
iterator to the newly added element

◆ emplace_back()

template<typename T , uint64_t Capacity>
template<typename... ConstructorArgs>
T & iox::cxx::list< T, Capacity >::emplace_back ( ConstructorArgs &&...  args)
noexcept

construct element inplace at end of list

Parameters
[in]argsT-typed construction parameters (initializer list)
Returns
referene to generated element, return is C++17-conform

◆ emplace_front()

template<typename T , uint64_t Capacity>
template<typename... ConstructorArgs>
T & iox::cxx::list< T, Capacity >::emplace_front ( ConstructorArgs &&...  args)
noexcept

construct element inplace at begining of list

Parameters
[in]argsT-typed construction parameters (initializer list)
Returns
referene to generated element, return is C++17-conform

◆ empty()

template<typename T , uint64_t Capacity>
bool iox::cxx::list< T, Capacity >::empty ( ) const
noexcept

list meta information on filling

Returns
no elements in list (true), otherwise (false)

◆ end() [1/2]

template<typename T , uint64_t Capacity>
const_iterator iox::cxx::list< T, Capacity >::end ( ) const
noexcept

default list operation to retrieve an const_iterator to end of list (behind last valid element) Terminated when content is attemted to read (operator*, operator->)

Returns
iterator to end element, does not contain data.

◆ end() [2/2]

template<typename T , uint64_t Capacity>
iterator iox::cxx::list< T, Capacity >::end ( )
noexcept

default list operation to retrieve an interator to end of list (behind last valid element) Terminated when content is attemted to read (operator*, operator->)

Returns
iterator to end element, does not contain data.

◆ erase()

template<typename T , uint64_t Capacity>
iterator iox::cxx::list< T, Capacity >::erase ( const_iterator  iter)
noexcept

remove next element from linked iterator position element destructors will be invoked recursive calls to erase_after only delete each 2nd element

Parameters
[in]iteriterator linking the to-be-removed element
Returns
an (non-const_) iterator to the element after the removed element, returns end() element when reached end of list

◆ front() [1/2]

template<typename T , uint64_t Capacity>
const T & iox::cxx::list< T, Capacity >::front ( ) const
noexcept

Returns a reference to the first element in the container. calling front() on an empty list will terminate() the processing.

Returns
const reference to the first element

◆ front() [2/2]

template<typename T , uint64_t Capacity>
T & iox::cxx::list< T, Capacity >::front ( )
noexcept

Returns a reference to the first element in the container. calling front() on an empty list will terminate() the processing.

Returns
reference to the first element

◆ full()

template<typename T , uint64_t Capacity>
bool iox::cxx::list< T, Capacity >::full ( ) const
noexcept

list meta information on filling

Returns
whether list is full (filled with 'capacity' / 'max_size' elements) (true), otherwise (false)

◆ insert() [1/2]

template<typename T , uint64_t Capacity>
iterator iox::cxx::list< T, Capacity >::insert ( const_iterator  citer,
const T &  data 
)
noexcept

insert element before iterator position

Parameters
[in]citeriterator with the position to insert after
[in]datareference to element to add
Returns
iterator to the newly added element

◆ insert() [2/2]

template<typename T , uint64_t Capacity>
iterator iox::cxx::list< T, Capacity >::insert ( const_iterator  citer,
T &&  data 
)
noexcept

add element before the pointed-to element via move

Parameters
[in]citeriterator with the position to insert after
[in]datauniversal reference perfectly forwarded to client class
Returns
iterator to the newly added element

◆ max_size()

template<typename T , uint64_t Capacity>
size_type iox::cxx::list< T, Capacity >::max_size ( ) const
noexcept

list meta information, maximum number of elements the list can contain

Returns
list has been initialized with the following number of elements, same as capacity()

◆ operator=() [1/2]

template<typename T , uint64_t Capacity>
list & iox::cxx::list< T, Capacity >::operator= ( const list< T, Capacity > &  rhs)
noexcept

copy assignment, each element is copied (added) to the constructed list any existing elements in 'this'/lhs are removed (same behaviour as std::list : Assigns new contents to the container, replacing its current contents, and modifying its size accordingly.)

Parameters
[in]rhsis the list to copy from (same capacity)
Returns
reference to created list

◆ operator=() [2/2]

template<typename T , uint64_t Capacity>
list & iox::cxx::list< T, Capacity >::operator= ( list< T, Capacity > &&  rhs)
noexcept

move assignment, list is cleared and initialized, elements are moved from source list any existing elements in 'this'/lhs are removed (same behaviour as std::list : Assigns new contents to the container, replacing its current contents, and modifying its size accordingly.)

Parameters
[in]rhsis the list to move from ('source', same capacity)
Returns
reference to created list

◆ pop_back()

template<typename T , uint64_t Capacity>
bool iox::cxx::list< T, Capacity >::pop_back ( )
noexcept

remove the last element from the end of the list element destructor will be invoked

Returns
successful removal (true), otherwise no element could be taken from list (e.g. empty -> false)

◆ pop_front()

template<typename T , uint64_t Capacity>
bool iox::cxx::list< T, Capacity >::pop_front ( )
noexcept

remove the first element from the begining of the list element destructor will be invoked

Returns
successful removal (true), otherwise no element could be taken from list (e.g. empty -> false)

◆ push_back() [1/2]

template<typename T , uint64_t Capacity>
bool iox::cxx::list< T, Capacity >::push_back ( const T &  data)
noexcept

add element to the end of the list

Parameters
[in]datareference to data element
Returns
successful insertion (true), otherwise no element could be added to list (e.g. full -> false)

◆ push_back() [2/2]

template<typename T , uint64_t Capacity>
bool iox::cxx::list< T, Capacity >::push_back ( T &&  data)
noexcept

add element to the end of the list via move

Parameters
[in]datauniversal reference perfectly forwarded to client class
Returns
successful insertion (true), otherwise no element could be added to list (e.g. full -> false)

◆ push_front() [1/2]

template<typename T , uint64_t Capacity>
bool iox::cxx::list< T, Capacity >::push_front ( const T &  data)
noexcept

add element to the beginning of the list

Parameters
[in]datareference to data element
Returns
successful insertion (true), otherwise no element could be added to list (e.g. full -> false)

◆ push_front() [2/2]

template<typename T , uint64_t Capacity>
bool iox::cxx::list< T, Capacity >::push_front ( T &&  data)
noexcept

add element to the beginning of the list via move

Parameters
[in]datauniversal reference perfectly forwarded to client class
Returns
successful insertion (true), otherwise no element could be added to list (e.g. full -> false)

◆ remove()

template<typename T , uint64_t Capacity>
size_type iox::cxx::list< T, Capacity >::remove ( const T &  data)
noexcept

remove all elements which matches the given comparing element (compare by value) requires a the template type T to have operator== defined.

Parameters
[in]datavalue to compare to
Returns
the number of elements removed, return is C++20-conform

◆ remove_if()

template<typename T , uint64_t Capacity>
template<typename UnaryPredicate >
size_type iox::cxx::list< T, Capacity >::remove_if ( UnaryPredicate  pred)
noexcept

remove all elements which matches the provided comparison function requires a the template type T to have a operator== defined.

Parameters
[in]predunary predicate which returns true if the element should be removed
Returns
the number of elements removed, return is C++20-conform

◆ size()

template<typename T , uint64_t Capacity>
size_type iox::cxx::list< T, Capacity >::size ( ) const
noexcept

list meta information on filling

Returns
current number of elements in list @min returns min 0 @max returns max capacity

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