8#ifndef HPP_ALIB_MONOMEM_LIST
9#define HPP_ALIB_MONOMEM_LIST 1
11#if !defined (HPP_ALIB_MONOMEM_FWDS)
15#if !defined (HPP_ALIB_MONOMEM_MONOALLOCATOR)
19#if !defined (HPP_ALIB_MONOMEM_DETAIL_RECYCLER)
23#if !defined(HPP_ALIB_LANG_BIDILIST)
27namespace alib {
namespace monomem {
45 template<
typename T>
struct ListRecycler<T,
Recycling::Shared >{
using type= detail::RecyclerShared <detail::ListElement<T>>; };
46 template<
typename T>
struct ListRecycler<T,
Recycling::None >{
using type= detail::RecyclerVoid <detail::ListElement<T>>; };
68template<
typename T,
typename TRecycling>
105 if( elem !=
nullptr )
125 template<
typename TConstOrMutableElement>
137 #if !defined(ALIB_DOX)
138 friend class List<T, TRecycling>;
153 #if defined(ALIB_DOX)
158 template<
typename TMutable>
163 TIterator<
typename std::remove_const<TConstOrMutableElement>::type> ) )
202 return !(*
this == other);
321 for(
auto& element : copy )
337 #if defined(ALIB_DOX)
351 template<
typename TEnableIf= TRecycling,
376 if constexpr( !std::is_trivially_destructible<T>::value )
432 return list.isEmpty();
441 return !
list.isEmpty();
456 if( !
list.isEmpty() )
458 auto* elem=
list.first();
459 while( elem != &
list.hook )
483 recycler.disposeRecyclablesIfPrivate();
503 if( requiredRecyclables > 0 )
506 Element* newElements=
allocator->template AllocArray<Element>( requiredRecyclables );
507 for(
auto i= requiredRecyclables -2; i >= 0 ; --i )
508 newElements[i].next( &newElements[i + 1] );
510 recycler.recycle( &newElements[0], &newElements[requiredRecyclables - 1] );
529 "Reference to element requested on empty monomem::List")
532 for(
integer i= 0 ; i < idx ; ++i )
535 ALIB_ASSERT_ERROR( act !=
nullptr,
"MONOMEM/LIST",
"Element index out of bounds")
550 "Reference to element requested on empty monomem::List")
553 for(
integer i= 0 ; i < idx ; ++i )
556 ALIB_ASSERT_ERROR( act !=
nullptr,
"MONOMEM/LIST",
"Element index out of bounds")
568 "Reference to element requested on empty monomem::List")
569 return list.first()->data;
580 "Reference to element requested on empty monomem::List")
581 return list.first()->data;
591 "Reference to element requested on empty monomem::List")
592 return list.last()->data;
602 "Reference to element requested on empty monomem::List")
603 return list.last()->data;
618 new (&elem->
data) T(copy);
633 new (&elem->
data) T(std::move(move));
648 new (&elem->
data) T(copy);
649 list.pushEnd( elem );
662 new (&elem->
data) T(std::move(move));
663 list.pushEnd( elem );
675 new (&elem->
data) T(copy);
676 list.pushFront( elem );
689 new (&elem->
data) T(std::move(move));
690 list.pushFront( elem );
701 template<
typename... TArgs>
705 new (&elem->
data) T( std::forward<TArgs>(args)... );
717 template<
typename... TArgs>
722 new (&elem->
data) T( std::forward<TArgs>(args)... );
723 list.pushEnd( elem );
733 template<
typename... TArgs>
738 new (&elem->
data) T( std::forward<TArgs>(args)... );
739 list.pushFront( elem );
759 "Erase requested on empty monomem::List")
761 "Iterator end() given with monomem::List::Erase")
782 "MONOMEM/LIST",
"Erase requested on empty monomem::List")
793 while ( elem != last.
element );
828template<
typename T,
typename TRecycling = monomem::Recycling::Private>
ConstIterator cend() const
Iterator Insert(ConstIterator position, T &&move)
List(MonoAllocator *pAllocator, TSharedRecycler &pRecycler)
std::reverse_iterator< Iterator > ReverseIterator
integer RecyclablesCount() const
ConstReverseIterator crbegin() const
T & EmplaceFront(TArgs &&... args)
ConstReverseIterator rend() const
Iterator Emplace(ConstIterator position, TArgs &&... args)
detail::ListRecycler< T, TRecycling >::type recycler
ConstIterator end() const
Iterator Insert(ConstIterator position, const T ©)
ConstReverseIterator rbegin() const
T & PushBack(const T ©)
ConstIterator cbegin() const
TIterator< const T > ConstIterator
T & ElementAt(integer idx)
void ReserveRecyclables(integer expectedSize)
T & PushFront(const T ©)
MonoAllocator * allocator
const T & ElementAt(integer idx) const
std::reverse_iterator< ConstIterator > ConstReverseIterator
List(MonoAllocator *pAllocator)
ConstReverseIterator crend() const
Iterator Erase(ConstIterator first, ConstIterator last)
ConstIterator begin() const
T & EmplaceBack(TArgs &&... args)
Iterator Erase(ConstIterator position)
MonoAllocator * GetAllocator() const
lang::BidiListHelper< Element > list
ALIB_FORCE_INLINE char * Alloc(size_t size, size_t alignment)
#define ALIB_WARNINGS_RESTORE
#define ATMP_EQ( T, TEqual)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
#define ATMP_SELECT_IF_1TP(TParam, ...)
#define ATMP_T_IF(T, Cond)
static ALIB_FORCE_INLINE void Destruct(T *object)
monomem::List< T, TRecycling > List
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
void addBefore(TElement *elem)
void next(SidiNodeBase *p)
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(Element *start)
T data
The custom data object.