#include <list.hpp>
Implements a doubly linked list, likewise std::list
does. Memory for inserted elements is allocated using the MonoAllocator provided with the constructor.
Elements that are erased from the list will be recycled with subsequent insert operations. With that, remove and insert operations do not lead to leaked memory in the monotonic allocator.
It is allowed to use different allocator objects with insertions. However, the life-cycle of the allocated memory and the objects stored in this container has to be kept in sync by the user of this object. For more information on this topic see methods Clear and Reset.
T | The type of the contained objects. |
TRecycling | Denotes the type of recycling that is to be performed. Possible values are Recycling::Private (the default), Recycling::Shared or Recycling::None. |
Definition at line 57 of file monomem/fwds.hpp.
Public Types | |
using | ConstIterator = TIterator< const T > |
using | ConstReverseIterator = std::reverse_iterator< ConstIterator > |
using | Iterator = TIterator< T > |
using | ReverseIterator = std::reverse_iterator< Iterator > |
using | TSharedRecycler = lib::detail::SidiListHelper< Element > |
Inner Classes | |
struct | TIterator |
Public Methods | |
std::iterator_traits Interface | |
Iterator | begin () |
Iterator | end () |
ConstIterator | begin () const |
ConstIterator | end () const |
ConstIterator | cbegin () const |
ConstIterator | cend () const |
ReverseIterator | rbegin () |
ReverseIterator | rend () |
ConstReverseIterator | rbegin () const |
ConstReverseIterator | rend () const |
ConstReverseIterator | crbegin () const |
ConstReverseIterator | crend () const |
Construction/Destruction | |
List (const List ©) | |
List (List &&move) | |
List (MonoAllocator *pAllocator) | |
List (MonoAllocator *pAllocator, TSharedRecycler &pRecycler) | |
~List () | |
Allocation | |
MonoAllocator * | GetAllocator () const |
integer | RecyclablesCount () const |
Size and Capacity | |
integer | Size () const |
bool | IsEmpty () const |
bool | IsNotEmpty () const |
void | Clear () |
void | Reset () |
void | ReserveRecyclables (integer expectedSize) |
List Start/End 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 (ConstIterator position, const T ©) |
Iterator | Insert (ConstIterator position, T &&move) |
T & | PushBack (const T ©) |
T & | PushBack (T &&move) |
T & | PushFront (const T ©) |
T & | PushFront (T &&move) |
template<typename... TArgs> | |
Iterator | Emplace (ConstIterator position, TArgs &&... args) |
template<typename... TArgs> | |
T & | EmplaceBack (TArgs &&... args) |
template<typename... TArgs> | |
T & | EmplaceFront (TArgs &&... args) |
Element Removal | |
Iterator | Erase (ConstIterator position) |
Iterator | Erase (ConstIterator first, ConstIterator last) |
void | PopFront () |
void | PopBack () |
Protected Types | |
using | Element = detail::ListElement< T > |
Protected Fields | |
MonoAllocator * | allocator |
lib::detail::BidiListHelper< Element > | list |
detail::ListRecycler< T, TRecycling >::type | recycler |
Protected Methods | |
Element * | allocElement () |
using ConstIterator = TIterator<const T> |
using ConstReverseIterator = std::reverse_iterator<ConstIterator> |
|
protected |
using ReverseIterator = std::reverse_iterator<Iterator> |
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 Recycling::Shared.
|
inline |
Constructor accepting a pointer to the allocator.
pAllocator | The monotonic allocator to use. |
|
inlineexplicit |
|
inlineprotected |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Invokes the destructor of all elements and empties the list. All allocated internal elements are kept for future recycling. Hence, the invocation of this method with this value implies that associated monotonic allocator is not reset.
As the life-cycle of the monotonic allocator(s) used for insertions is not under control of this object, it is the obligation of the caller to ensure that the monotonic allocator is kept in sync with this object.
|
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 constructor of type T. |
|
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 |
Returns the allocator of this object. Usually the allocator might be used to perform allocations in respect to data found in objects stored in this object. However, such allowance is dependent on the use case and not part of this class's contract.
|
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.
This method may be helpful if the definite number of stored elements that is never exceeded is known. In this case, a snapshot of the monotonic allocator could be taken after the invocation of this method and then used to reset the monotonic allocator with preserving the memory used by this container.
expectedSize | The expected number of elements to be stored in the hash table. |
|
inline |
Invokes Clear and in case of private recycling disposes all previously allocated recyclable instances of internal element type.
Hence, the invocation of this method with this value usually implies that the monotonic allocator used is reset as well.
As the life-cycle of the monotonic allocator(s) used for insertions is not under control of this object, it is the obligation of the caller to ensure that the monotonic allocator is kept in sync with this object.
|
inline |
|
protected |
|
protected |
|
protected |