Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
LinkedElements< N, ALO > Class Template Reference

#include "lib/linked-elements.hpp"

Description

template<class N, class ALO = linked_elements::OwningHeapAllocated<N>>
class lib::LinkedElements< N, ALO >

Intrusive single linked list, possibly taking ownership of node elements.

Additional elements can be pushed (prepended) to the list; element access is per index number (slow) or through an Lumiera Forward Iterator traversing the linked list. There is no support for changing the list contents aside of discarding any element in the list.

The allocation and ownership related behaviour is controlled by a policy class provided as template parameter. When this policy supports creation of new elements, these might be created and prepended in one step.

Note
with the default policy, sizeof(LinkedElements) == sizeof(N*)

Definition at line 158 of file linked-elements.hpp.

Classes

struct  IterationState
 Iteration is just following the single linked list. More...
 

Public Types

using iterator = IterStateWrapper< IterationState, N & >
 
using const_iterator = IterStateWrapper< IterationState, const N & >
 

Public Member Functions

 ~LinkedElements () noexcept
 
 LinkedElements ()
 
 LinkedElements (LinkedElements const &)=default
 
 LinkedElements (LinkedElements &&rr)
 
 LinkedElements (ALO::CustomAllocator allo)
 
template<class IT >
 LinkedElements (IT &&elements)
 creating a LinkedElements list in RAII-style:
 
void clear () noexcept
 
template<class IT >
void pushAll (IT elements)
 convenience shortcut to add all the elements yielded by the given Lumiera Forward Iterator
 
template<typename TY >
TY & push (TY &elm) noexcept
 accept the given element and prepend it to the list of elements; depending on the allocation policy, this might imply taking ownership
 
template<class TY = N, typename... ARGS>
TY & emplace (ARGS &&...args)
 prepend object of type TY, forwarding ctor args
 
LinkedElementsreverse ()
 Mutate the complete list to change the order of elements.
 
N & operator[] (size_t index) const
 
N & top () const
 
size_t size () const
 
bool empty () const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 

Private Attributes

N * head_
 

Additional Inherited Members

- Private Types inherited from OwningAllocated< ALO >
using CustomAllocator = ALO
 
- Private Member Functions inherited from StdFactory< ALO >
 StdFactory (Allo allo=Allo{})
 Create an instance of the adapter factory, forwarding to the embedded standard conforming allocator for object creation and destruction and memory management.
 
template<class XALO >
bool constexpr operator== (StdFactory< XALO > const &o) const
 
template<class XALO >
bool constexpr operator!= (StdFactory< XALO > const &o) const
 
template<class TY , typename... ARGS>
TY * create (ARGS &&...args)
 create new element using the embedded allocator
 
template<class TY >
void dispose (TY *elm)
 destroy the given element and discard the associated memory
 
- Private Member Functions inherited from MoveOnly
 ~MoveOnly ()=default
 
 MoveOnly ()=default
 
 MoveOnly (MoveOnly &&)=default
 
 MoveOnly (MoveOnly const &)=delete
 
MoveOnlyoperator= (MoveOnly &&)=delete
 
MoveOnlyoperator= (MoveOnly const &)=delete
 

Constructor & Destructor Documentation

◆ ~LinkedElements()

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
~LinkedElements ( )
inlinenoexcept

Definition at line 166 of file linked-elements.hpp.

References LinkedElements< N, ALO >::clear().

+ Here is the call graph for this function:

◆ LinkedElements() [1/5]

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
LinkedElements ( )
inline

Definition at line 171 of file linked-elements.hpp.

◆ LinkedElements() [2/5]

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
LinkedElements ( LinkedElements< N, ALO > const &  )
default

◆ LinkedElements() [3/5]

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
LinkedElements ( LinkedElements< N, ALO > &&  rr)
inline

Definition at line 176 of file linked-elements.hpp.

◆ LinkedElements() [4/5]

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
LinkedElements ( ALO::CustomAllocator  allo)
inlineexplicit
Parameters
allocustom allocator or memory manager to be used by the policy for creating and discarding of node elements

Definition at line 187 of file linked-elements.hpp.

◆ LinkedElements() [5/5]

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
template<class IT >
LinkedElements ( IT &&  elements)
inline

creating a LinkedElements list in RAII-style:

Parameters
elementsiterator to provide all the elements to be pushed into this newly created collection
Note
any exception while populating the container causes already created elements to be destroyed

Definition at line 200 of file linked-elements.hpp.

References LinkedElements< N, ALO >::clear(), lib::elements(), and LinkedElements< N, ALO >::pushAll().

+ Here is the call graph for this function:

Member Typedef Documentation

◆ iterator

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
using iterator = IterStateWrapper<IterationState, N&>

Definition at line 397 of file linked-elements.hpp.

◆ const_iterator

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
using const_iterator = IterStateWrapper<IterationState, const N&>

Definition at line 398 of file linked-elements.hpp.

Member Function Documentation

◆ clear()

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
void clear ( )
inlinenoexcept
Note
EX_FREE

Definition at line 218 of file linked-elements.hpp.

References ERROR_LOG_AND_IGNORE, and LinkedElements< N, ALO >::head_.

Referenced by LinkedElements< N, ALO >::LinkedElements(), LinkedElements< N, ALO >::~LinkedElements(), and AllocationCluster::StorageManager::discardAll().

+ Here is the caller graph for this function:

◆ pushAll()

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
template<class IT >
void pushAll ( IT  elements)
inline

convenience shortcut to add all the elements yielded by the given Lumiera Forward Iterator

Note
EX_SANE

Definition at line 238 of file linked-elements.hpp.

References lib::elements(), and LinkedElements< N, ALO >::push().

Referenced by LinkedElements< N, ALO >::LinkedElements().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ push()

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
template<typename TY >
TY & push ( TY &  elm)
inlinenoexcept

accept the given element and prepend it to the list of elements; depending on the allocation policy, this might imply taking ownership

Note
EX_STRONG

Definition at line 253 of file linked-elements.hpp.

References LinkedElements< N, ALO >::head_.

Referenced by AllocationCluster::StorageManager::attach(), LinkedElements< N, ALO >::emplace(), LinkedElements< N, ALO >::pushAll(), and LinkedElements< N, ALO >::reverse().

+ Here is the caller graph for this function:

◆ emplace()

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
template<class TY = N, typename... ARGS>
TY & emplace ( ARGS &&...  args)
inline

prepend object of type TY, forwarding ctor args

Definition at line 265 of file linked-elements.hpp.

References LinkedElements< N, ALO >::push().

Referenced by AllocationCluster::StorageManager::prependNextBlock().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reverse()

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
LinkedElements & reverse ( )
inline

Mutate the complete list to change the order of elements.

Remarks
since pushing prepends, elements are initially in reverse order
Warning
this operation invalidates iterators and has O(n) cost; ownership and elements themselves are not affected.

Definition at line 279 of file linked-elements.hpp.

References LinkedElements< N, ALO >::empty(), LinkedElements< N, ALO >::head_, and LinkedElements< N, ALO >::push().

+ Here is the call graph for this function:

◆ operator[]()

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
N & operator[] ( size_t  index) const
inline

Definition at line 300 of file linked-elements.hpp.

References LinkedElements< N, ALO >::head_, and LERR_.

◆ top()

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
N & top ( ) const
inline
Warning
unchecked

Definition at line 319 of file linked-elements.hpp.

References LinkedElements< N, ALO >::head_.

Referenced by AllocationCluster::StorageManager::prependNextBlock().

+ Here is the caller graph for this function:

◆ size()

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
size_t size ( ) const
inline
Warning
traverses to count the elements

Definition at line 328 of file linked-elements.hpp.

References LinkedElements< N, ALO >::head_.

◆ empty()

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
bool empty ( ) const
inline

Definition at line 342 of file linked-elements.hpp.

References LinkedElements< N, ALO >::head_.

Referenced by LinkedElements< N, ALO >::reverse().

+ Here is the caller graph for this function:

◆ begin() [1/2]

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
iterator begin ( )
inline

Definition at line 401 of file linked-elements.hpp.

References LinkedElements< N, ALO >::head_.

Referenced by JobTicket::getPrerequisites().

+ Here is the caller graph for this function:

◆ begin() [2/2]

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
const_iterator begin ( ) const
inline

Definition at line 402 of file linked-elements.hpp.

References LinkedElements< N, ALO >::head_.

◆ end() [1/2]

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
iterator end ( )
inline

Definition at line 403 of file linked-elements.hpp.

◆ end() [2/2]

template<class N , class ALO = linked_elements::OwningHeapAllocated<N>>
const_iterator end ( ) const
inline

Definition at line 404 of file linked-elements.hpp.

Member Data Documentation

◆ head_

+ Inheritance diagram for LinkedElements< N, ALO >:
+ Collaboration diagram for LinkedElements< N, ALO >:

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