8#ifndef HPP_ALIB_MONOMEM_CONTAINERS_LIST
9#define HPP_ALIB_MONOMEM_CONTAINERS_LIST 1
15#include "alib/containers/recycler.hpp"
68template<
typename TAllocator,
typename T, Recycling TRecycling= Recycling::Private>
71 detail::ListElement<T> >
72#if ALIB_DEBUG_CRITICAL_SECTIONS
104 ::template HookType<TAllocator, detail::ListElement<T> >;
120 template<
typename TConstOrMutableElement>
133 friend class List<TAllocator, T, TRecycling>;
152 template<
typename TMutable>
157 TIterator<
typename std::remove_const<TConstOrMutableElement>::type> ) )
196 return !(*
this == other);
307 #if ALIB_DEBUG_CRITICAL_SECTIONS
321 List(std::initializer_list<T> initList)
324 for (
const auto& item : initList)
342 for(
auto& element : copy )
353 :
hook ( std::move( move.list ) )
386 for (
const auto& item : initList)
398 List(TSharedRecycler& pSharedRecycler )
415 List(TSharedRecycler& pSharedRecycler, std::initializer_list<T> initList)
416 :
List(pSharedRecycler)
418 for (
const auto& item : initList)
519 recyclerType::Reset();
534 auto requiredRecyclables= ( qty
537 - recyclerType::Count();
539 if( requiredRecyclables > 0 )
540 recyclerType::Reserve( requiredRecyclables );
557 "Reference to element requested on empty containers::List")
560 for(
integer i= 0 ; i < idx ; ++i )
563 ALIB_ASSERT_ERROR( act !=
nullptr,
"MONOMEM/LIST",
"Element index out of bounds")
578 "Reference to element requested on empty containers::List")
581 for(
integer i= 0 ; i < idx ; ++i )
584 ALIB_ASSERT_ERROR( act !=
nullptr,
"MONOMEM/LIST",
"Element index out of bounds")
596 "Reference to element requested on empty containers::List")
608 "Reference to element requested on empty containers::List")
619 "Reference to element requested on empty containers::List")
630 "Reference to element requested on empty containers::List")
645 Element* elem= recyclerType::Get();
646 new (&elem->data) T(copy);
660 Element* elem= recyclerType::Get();
661 new (&elem->data) T(std::move(move));
674 Element* elem= recyclerType::Get();
676 new (&elem->data) T(copy);
688 Element* elem= recyclerType::Get();
690 new (&elem->data) T(std::move(move));
702 Element* elem= recyclerType::Get();
703 new (&elem->data) T(copy);
715 Element* elem= recyclerType::Get();
717 new (&elem->data) T(std::move(move));
729 template<
typename... TArgs>
732 Element* elem= recyclerType::Get();
733 new (&elem->data) T( std::forward<TArgs>(args)... );
745 template<
typename... TArgs>
748 Element* elem= recyclerType::Get();
750 new (&elem->data) T( std::forward<TArgs>(args)... );
761 template<
typename... TArgs>
764 Element* elem= recyclerType::Get();
766 new (&elem->data) T( std::forward<TArgs>(args)... );
787 "Erase requested on empty containers::List")
789 "Iterator end() given with containers::List::Erase")
794 recyclerType::Recycle( position.
element );
809 "MONOMEM/LIST",
"Erase requested on empty containers::List")
841template<
typename TAllocator,
typename T, Recycling TRecycling = containers::Recycling::Private>
ConstIterator cend() const
Iterator Insert(ConstIterator position, T &&move)
List(std::initializer_list< T > initList)
Iterator Erase(ConstIterator begin, ConstIterator end)
List(TSharedRecycler &pSharedRecycler, std::initializer_list< T > initList)
std::reverse_iterator< Iterator > ReverseIterator
The mutable iterator exposed by this container.
integer RecyclablesCount() const
ConstReverseIterator crbegin() const
T & EmplaceFront(TArgs &&... args)
ConstReverseIterator rend() const
Iterator Emplace(ConstIterator position, TArgs &&... args)
ConstIterator end() const
Iterator Insert(ConstIterator position, const T ©)
~List()
Destructor. Invokes Clear.
ConstReverseIterator rbegin() const
T & PushBack(const T ©)
TAllocator AllocatorType
The allocator type that TAllocator specifies.
ConstIterator cbegin() const
List(AllocatorType &pAllocator)
List(AllocatorType &pAllocator, std::initializer_list< T > initList)
TIterator< const T > ConstIterator
The constant iterator exposed by this container.
typename detail::RecyclingSelector< TRecycling > ::template HookType< TAllocator, detail::ListElement< T > > SharedRecyclerType
T & ElementAt(integer idx)
T & PushFront(const T ©)
void PopBack()
Removes the last element.
const T & ElementAt(integer idx) const
typename detail::RecyclingSelector< TRecycling >::template Type< TAllocator, detail::ListElement< T > > recyclerType
The recycler type.
std::reverse_iterator< ConstIterator > ConstReverseIterator
The constant iterator exposed by this container.
ConstReverseIterator crend() const
List(TSharedRecycler &pSharedRecycler)
void ReserveRecyclables(integer qty, lang::ValueReference reference)
ConstIterator begin() const
T & EmplaceBack(TArgs &&... args)
Iterator Erase(ConstIterator position)
AllocatorType & GetAllocator()
void PopFront()
Removes the first element.
TIterator< T > Iterator
The mutable iterator exposed by this container.
#define ALIB_ASSERT_MODULE(modulename)
#define ATMP_EQ( T, TEqual)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_DCS_WITH(CS)
#define ATMP_SELECT_IF_1TP(TParam, ...)
#define ATMP_T_IF(T, Cond)
#define ALIB_DEBUG_CRITICAL_SECTIONS
ValueReference
Denotes if a value is interpreted as an absolute or relative number.
@ Absolute
Referring to an absolute value.
lang::integer integer
Type alias in namespace alib.
TIterator operator--(int)
std::bidirectional_iterator_tag iterator_category
Implementation of std::iterator_traits.
TConstOrMutableElement * operator->() const
TIterator(const TMutable &mutableIt)
TConstOrMutableElement value_type
Implementation of std::iterator_traits.
TIterator operator++(int)
bool operator==(TIterator other) const
bool operator!=(TIterator other) const
Element * element
The actual element of the list.
TConstOrMutableElement * pointer
Implementation of std::iterator_traits.
TConstOrMutableElement & operator*() const
integer difference_type
Implementation of std::iterator_traits.
TConstOrMutableElement & reference
Implementation of std::iterator_traits.
TIterator()=default
Default constructor creating an invalid iterator.
TIterator(Element *start)
Extents BidiNodeBase by an value of type T.
T data
The custom data object.
TAllocator & GetAllocator() const noexcept
detail::ListElement< T > * popFront() noexcept
void pushFront(detail::ListElement< T > *elem) noexcept
integer count(const TNode *end=nullptr) const noexcept
detail::ListElement< T > * first() const noexcept
void pushEnd(detail::ListElement< T > *elem) noexcept
detail::ListElement< T > * last() const noexcept
bool isEmpty() const noexcept
detail::ListElement< T > * end() const noexcept
detail::ListElement< T > * popEnd() noexcept
void remove() noexcept
Unhooks this node from a list.
TElement * prev() const noexcept
void addBefore(TElement *elem) noexcept
ALIB_FORCE_INLINE DbgCriticalSections(const char *name)
void next(SidiNodeBase *p)