Implements a doubly linked list, likewise std::list
does. Memory for inserted elements is allocated using the Allocator provided with construction.
Elements that are erased from the list will by default be recycled with subsequent insert operations. With that, remove and insert operations do not lead to leaked memory when a monotonic allocator is used.
This type is not a full re-write of type std::list
. Among others, as of today, methods splice
, merge
, or sort
are not provided.
Inner Type Index: | |
struct | TIterator |
Public Type Index: | |
using | AllocatorType = TAllocator |
The allocator type that TAllocator specifies. | |
using | const_iterator = TIterator<const T> |
The constant iterator exposed by this container. | |
using | const_reverse_iterator = std::reverse_iterator<const_iterator> |
The constant iterator exposed by this container. | |
using | iterator = TIterator< T> |
The mutable iterator exposed by this container. | |
using | reverse_iterator = std::reverse_iterator<iterator> |
The mutable iterator exposed by this container. | |
using | SharedRecyclerType |
using | size_type = integer |
The type defining sizes of this container. | |
using | value_type = T |
Exposes template parameter T to the outer world in a std compatible way. | |
Public Method Index: | |
std::iterator_traits Interface | |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
const_iterator | cbegin () const |
const_iterator | cend () const |
reverse_iterator | rbegin () |
reverse_iterator | rend () |
const_reverse_iterator | rbegin () const |
const_reverse_iterator | rend () const |
const_reverse_iterator | crbegin () const |
const_reverse_iterator | crend () const |
List () | |
List (std::initializer_list< T > initList) | |
List (const List ©) | |
List (List &&move) | |
List (AllocatorType &pAllocator) | |
List (AllocatorType &pAllocator, std::initializer_list< T > initList) | |
template<typename TSharedRecycler = SharedRecyclerType> requires (!std::same_as<TSharedRecycler , void>) | |
List (TSharedRecycler &pSharedRecycler) | |
template<typename TSharedRecycler = SharedRecyclerType> requires (!std::same_as<TSharedRecycler , void>) | |
List (TSharedRecycler &pSharedRecycler, std::initializer_list< T > initList) | |
~List () | |
Destructor. Invokes Clear. | |
Allocation | |
AllocatorType & | GetAllocator () |
integer | RecyclablesCount () const |
Size and Capacity | |
integer | size () const |
bool | empty () const |
bool | IsNotEmpty () const |
void | Clear () |
void | Reset () |
void | ReserveRecyclables (integer qty, lang::ValueReference reference) |
Element Access | |
T & | ElementAt (integer idx) |
const T & | ElementAt (integer idx) const |
T & | front () |
const T & | front () const |
T & | back () |
const T & | back () const |
Element Insertion | |
iterator | Insert (const_iterator position, const T ©) |
iterator | Insert (const_iterator position, T &&move) |
T & | push_back (const T ©) |
T & | push_back (T &&move) |
T & | push_front (const T ©) |
T & | push_front (T &&move) |
template<typename... TArgs> | |
iterator | emplace (const_iterator position, TArgs &&... args) |
template<typename... TArgs> | |
T & | emplace_back (TArgs &&... args) |
template<typename... TArgs> | |
T & | emplace_front (TArgs &&... args) |
Element Removal | |
iterator | erase (const_iterator position) |
iterator | erase (const_iterator begin, const_iterator end) |
void | pop_front () |
Removes the first element. | |
void | pop_back () |
Removes the last element. | |
![]() | |
DbgCriticalSections (const char *name) | |
~DbgCriticalSections () | |
Destructor. Checks that this instance is unused. | |
ALIB_DLL void | Acquire (const CallerInfo &ci) const |
ALIB_DLL void | AcquireShared (const CallerInfo &ci) const |
ALIB_DLL void | doAssert (bool cond, const CallerInfo &ciAssert, const CallerInfo &ci, const char *headline) const |
ALIB_DLL void | Release (const CallerInfo &ci) const |
ALIB_DLL void | ReleaseShared (const CallerInfo &ci) const |
void | yieldOrSleep () const |
Protected Type Index: | |
using | allocBase = lang::AllocatorMember<TAllocator> |
The allocator type that TAllocator specifies. | |
using | Element = detail::ListElement<T> |
The list element type. | |
using | hook = lang::BidiListHook<detail::ListElement<T>> |
The allocator type that TAllocator specifies. | |
using | recyclerType |
The recycler type. | |
Additional Inherited Members | |
![]() | |
static ALIB_DLL const char * | ASSERTION_FORMAT |
![]() | |
CallerInfo | DCSAcq |
Source location of acquirement. | |
AssociatedLock * | DCSLock {nullptr} |
const char * | DCSName |
The name of this DCS. Used for debug-output. | |
std::atomic< int > | DCSReaderCnt {0} |
Tracks enter/exit calls of readers. | |
CallerInfo | DCSRel |
Source location of the last "reader" seen. | |
CallerInfo | DCSSAcq |
Source location of acquirement. | |
CallerInfo | DCSSRel |
Source location of the last "reader" seen. | |
std::atomic< int > | DCSWriterCnt {0} |
Tracks enter/exit calls (including readers) | |
int | DCSYieldOrSleepTimeInNS = -1 |
![]() | |
using | TFNode |
An alias for the base type of the node type of this list. | |
using | TFNode |
An alias for the base type of the node type of this list. | |
using | TNode |
An alias for the node type of this list. | |
using | TNode |
An alias for the node type of this list. | |
![]() | |
TNode | hook |
The root node. Points twice to itself when the list is empty. | |
TNode | hook |
The root node. Points twice to itself when the list is empty. | |
![]() | |
BidiListHook () noexcept | |
Default constructor. Initializes this list to be empty. | |
BidiListHook () noexcept | |
Default constructor. Initializes this list to be empty. | |
BidiListHook (BidiListHook &&move) noexcept | |
BidiListHook (BidiListHook &&move) noexcept | |
BidiListHook (const BidiListHook &)=delete | |
Deleted copy constructor. | |
BidiListHook (const BidiListHook &)=delete | |
Deleted copy constructor. | |
BidiListHook (detail::ListElement< T > *first) noexcept | |
BidiListHook (detail::ListElement< T > *first) noexcept | |
BidiListHook (detail::ListElement< T > *first, detail::ListElement< T > *last) noexcept | |
BidiListHook (detail::ListElement< T > *first, detail::ListElement< T > *last) noexcept | |
integer | count (const TNode *end=nullptr) const noexcept |
integer | count (const TNode *end=nullptr) const noexcept |
detail::ListElement< T > * | end () const noexcept |
detail::ListElement< T > * | end () const noexcept |
detail::ListElement< T > * | first () const noexcept |
detail::ListElement< T > * | first () const noexcept |
bool | isEmpty () const noexcept |
bool | isEmpty () const noexcept |
bool | isFirst (const detail::ListElement< T > *elem) const noexcept |
bool | isFirst (const detail::ListElement< T > *elem) const noexcept |
bool | isLast (const detail::ListElement< T > *elem) const noexcept |
bool | isLast (const detail::ListElement< T > *elem) const noexcept |
detail::ListElement< T > * | last () const noexcept |
detail::ListElement< T > * | last () const noexcept |
BidiListHook & | operator= (BidiListHook &&) noexcept=default |
BidiListHook & | operator= (BidiListHook &&) noexcept=default |
BidiListHook & | operator= (const BidiListHook &)=delete |
BidiListHook & | operator= (const BidiListHook &)=delete |
detail::ListElement< T > * | popEnd () noexcept |
detail::ListElement< T > * | popEnd () noexcept |
detail::ListElement< T > * | popFront () noexcept |
detail::ListElement< T > * | popFront () noexcept |
void | pushEnd (detail::ListElement< T > *elem) noexcept |
void | pushEnd (detail::ListElement< T > *elem) noexcept |
void | pushEnd (detail::ListElement< T > *first, detail::ListElement< T > *last) noexcept |
void | pushEnd (detail::ListElement< T > *first, detail::ListElement< T > *last) noexcept |
void | pushFront (detail::ListElement< T > *elem) noexcept |
void | pushFront (detail::ListElement< T > *elem) noexcept |
void | pushFront (detail::ListElement< T > *first, detail::ListElement< T > *last) noexcept |
void | pushFront (detail::ListElement< T > *first, detail::ListElement< T > *last) noexcept |
void | reset () noexcept |
Resets this list to zero elements. | |
void | reset () noexcept |
Resets this list to zero elements. | |
using alib::containers::List< TAllocator, T, TRecycling >::AllocatorType = TAllocator |
|
protected |
using alib::containers::List< TAllocator, T, TRecycling >::const_iterator = TIterator<const T> |
using alib::containers::List< TAllocator, T, TRecycling >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
|
protected |
|
protected |
using alib::containers::List< TAllocator, T, TRecycling >::iterator = TIterator< T> |
|
protected |
The recycler type.
using alib::containers::List< TAllocator, T, TRecycling >::reverse_iterator = std::reverse_iterator<iterator> |
using alib::containers::List< TAllocator, T, TRecycling >::SharedRecyclerType |
This type definition may be used to define an externally managed shared recycler, which can be passed to the alternative constructor of this class when template parameter TRecycling equals Shared.
using alib::containers::List< TAllocator, T, TRecycling >::size_type = integer |
using alib::containers::List< TAllocator, T, TRecycling >::value_type = T |
|
inline |
Constructor neither requiring an allocator, nor a shared recycler.
|
inline |
|
inline |
|
inline |
|
inline |
Constructor accepting an allocator.
pAllocator | The allocator to use. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Adds a new element before the given position.
TArgs | Types of variadic parameters given with parameter args. |
position | The position to emplace the new element. |
args | Variadic parameters to be forwarded to the constructor of type T. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Removes an element at the given position.
position | A constant iterator pointing to the element to be removed. Mutable iterators are inherently converted with the invocation of this method. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Counts the number of currently allocated but unused (not contained) list elements that will be recycled with upcoming insertions.
|
inline |
|
inline |
|
inline |
Allocates the required memory for the number of additional elements expected.
qty | The expected resulting number (or increase) of elements to be stored in this container. |
reference | Denotes whether qty is meant as an absolute size or an increase. |
|
inline |
Same as clear, but does not recycle internal nodes. Furthermore, all recyclables are deleted. The latter is done only if recycling type is not Shared. In this case, the elements are still recycled.
This method is useful with monotonic allocators, that can be reset as well, after this instance is reset.
|
inline |