ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
list.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of module \alib_containers of the \aliblong.
4///
5/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
6/// Published under #"mainpage_license".
7//==================================================================================================
8
9/// Detail namespace of module \alib_containers.
11
12/// Extents \b BidiNodeBase by an value of type \p{T}.
13template<typename T>
14struct ListElement : public lang::BidiNodeBase<ListElement<T>>
15{
16 T data; ///< The custom data object.
17};
18
19} // namespace [alib::containers::detail]
20
21
22ALIB_EXPORT namespace alib {
23
24/// This is the reference documentation of namespace <c>%alib::containers</c>, which
25/// holds types of module \alib_containers_nl, which in turn is part of the \aliblink.
26///
27/// Extensive documentation for this module is provided with the
28/// #"alib_mods_contmono;Programmer's Manual" of this module.
29namespace containers {
30
31
32//==================================================================================================
33/// TODO(251224 09:26): Add a template parameter which enables element counting.
34/// Add a size method that is available only if size counting is activated.
35/// TODO(251224 09:26): Implement forwardList. Ich weiss, es ist kaum nötig, aber die
36/// basis-typen sind einfach unbrauchbar. Vielleicht kann die KI es ja machen ;-)
37/// Implements a doubly linked list, likewise \c std::list does. Memory for inserted elements is
38/// allocated using the #"lang::Allocator" provided with construction.
39///
40/// Elements that are erased from the list will by default be recycled with subsequent insert
41/// operations. With that, remove and insert operations do not lead to leaked memory when a
42/// monotonic allocator is used.
43///
44/// This type is not a full re-write of type \c std::list. Among others, as of today,
45/// methods \c splice, \c merge, or \c sort are not provided.
46///
47/// @see
48/// - Chapter #"alib_contmono_containers_types" of the joint Programmer's Manuals of modules
49/// \alib_containers and \alib_monomem.
50/// - Chapter #"alib_threads_intro_assert_entry" of the Programmer's Manual of module
51/// \alib_threads for information about debugging multithreaded access on instances of this
52/// type.
53///
54/// @tparam T The type of the contained objects.
55/// @tparam TAllocator The allocator type to use.
56/// @tparam TRecycling Denotes the type of recycling that is to be performed. Possible values are
57/// #"Recycling::None",
58/// #"Recycling::Private" (the default), or
59/// #"Recycling::Shared".
60//==================================================================================================
61template<typename T, typename TAllocator, Recycling TRecycling= Recycling::Private>
62class List : lang::BidiListHook<detail::ListElement<T>>
63 , detail::RecyclingSelector<TRecycling>:: template Type< TAllocator,
64 detail::ListElement<T> >
65#if ALIB_DEBUG_CRITICAL_SECTIONS
67#endif
68{
69 //################################################################################################
70 // Node/Element type
71 //################################################################################################
72 protected:
73 /// The hook type.
75
76 /// The type of the base class that stores the allocator.
78
79 /// The list element type.
81
82 /// The recycler type.
83 using recyclerType= typename detail::RecyclingSelector<TRecycling>:: template Type< TAllocator,
85
86 public:
87 /// Exposes template parameter \p{T} to the outer world in a \c std compatible way.
88 using value_type = T;
89
90 /// The type defining sizes of this container.
92
93
94 /// The allocator type that \p{TAllocator} specifies.
95 using AllocatorType= TAllocator;
96
97 /// This type definition may be used to define an externally managed shared recycler,
98 /// which can be passed to the alternative constructor of this class when template
99 /// parameter \p{TRecycling} equals #"Recycling::Shared".
100 /// \see
101 /// Chapter #"alib_contmono_containers_recycling_shared" of the Programmer's Manual
102 /// for this \alibmod.
104 ::template HookType<TAllocator, detail::ListElement<T> >;
105
106 //################################################################################################
107 // std::iterator_traits
108 //################################################################################################
109 protected:
110
111 /// Implementation of \c std::iterator_traits for this container.
112 ///
113 /// As the name of the class indicates, this iterator satisfies the C++ standard library
114 /// concept
115 /// \https{BidirectionalIterator,en.cppreference.com/w/cpp/named_req/BidirectionalIterator}.
116 ///
117 /// @tparam TConstOrMutableElement The custom data type as either <c>const</c> or mutable.
118 template<typename TConstOrMutableElement>
120 {
121 using iterator_category = std::bidirectional_iterator_tag; ///< Implementation of <c>std::iterator_traits</c>.
122 using value_type = TConstOrMutableElement ; ///< Implementation of <c>std::iterator_traits</c>.
123 using difference_type = integer ; ///< Implementation of <c>std::iterator_traits</c>.
124 using pointer = TConstOrMutableElement* ; ///< Implementation of <c>std::iterator_traits</c>.
125 using reference = TConstOrMutableElement& ; ///< Implementation of <c>std::iterator_traits</c>.
126
127 protected:
128 Element* element; ///< The actual element of the list.
129
130 #if !DOXYGEN
131 friend class List<T, TAllocator, TRecycling>;
132 #endif
133
134 public:
135
136 /// Default constructor creating an invalid iterator.
137 TIterator() =default;
138
139 /// Constructor.
140 /// @param start Pointer to the initial element.
141 explicit TIterator( Element* start )
142 : element( start ) {}
143
144 /// Copy constructor accepting a mutable iterator.
145 /// Available only for the constant version of this iterator.
146 /// @tparam TMutable The type of this constructor's argument.
147 /// @param mutableIt Mutable iterator to copy from.
148 template<typename TMutable>
149 requires std::same_as<TMutable,
151 TIterator( const TMutable& mutableIt ) : element( mutableIt.element ) {}
152
153 //############################ To satisfy concept of InputIterator ##########################
154
155 /// Prefix increment operator.
156 /// @return A reference to this object.
157 TIterator& operator++() { element= element->next(); return *this; }
158
159 /// Postfix increment operator.
160 /// @return An iterator value that is not increased, yet.
162 auto result= TIterator(element);
163 element= element->next();
164 return result;
165 }
166
167 /// Comparison operator.
168 /// @param other The iterator to compare ourselves to.
169 /// @return \c true if this and the given iterator are pointing to the same element,
170 /// \c false otherwise.
171 bool operator==(TIterator other) const { return element == other.element; }
172
173 /// Comparison operator.
174 /// @param other The iterator to compare ourselves to.
175 /// @return \c true if this and given iterator are not equal, \c false otherwise.
176 bool operator!=(TIterator other) const { return !(*this == other); }
177
178 //######################## To satisfy concept of BidirectionalIterator ######################
179
180 /// Prefix decrement operator.
181 /// @return A reference to this object.
182 TIterator& operator--() { element= element->prev(); return *this; }
183
184 /// Postfix decrement operator.
185 /// @return The iterator value prior the decrement operation.
187 auto result= TIterator(element);
188 element= element->prev();
189 return result;
190 }
191
192 //####################################### Member access ######################################
193
194 /// Retrieves a reference to the referred element.
195 /// @return A reference to the referred element.
196 TConstOrMutableElement& operator*() const { return element->data; }
197
198 /// Retrieves a pointer to the referred element.
199 /// @return A pointer to the referred element.
200 TConstOrMutableElement* operator->() const { return &element->data; }
201
202 }; // struct TIterator
203
204 public:
205 /// The constant iterator exposed by this container.
207
208 /// The mutable iterator exposed by this container.
210
211 /// The constant iterator exposed by this container.
212 using const_reverse_iterator= std::reverse_iterator<const_iterator>;
213
214 /// The mutable iterator exposed by this container.
215 using reverse_iterator = std::reverse_iterator<iterator>;
216
217 //##############################################################################################
218 /// @name std::iterator_traits Interface
219 //##############################################################################################
220 /// Returns an iterator pointing to a mutable value at the start of this list.
221 /// @return The start of this list.
223
224 /// Returns an iterator pointing to the first element behind this list.
225 /// @return The end of this list.
226 iterator end() { return iterator( hook::end() ); }
227
228 /// Returns an iterator pointing to a constant value at the start of this list.
229 /// @return The start of this list.
231
232 /// Returns an iterator pointing to the first element behind this list.
233 /// @return The end of this list.
235
236 /// Returns an iterator pointing to a constant value at the start of this list.
237 /// @return The start of this list.
239
240 /// Returns an iterator pointing to the first element behind this list.
241 /// @return The end of this list.
243
244 /// Returns a reverse iterator pointing to a mutable value at the end of this list.
245 /// @return The start of this list.
247
248 /// Returns a reverse iterator pointing to the first element behind the start of this list.
249 /// @return The end of this list.
251
252 /// Returns a reverse iterator pointing to a constant value at the end of this list.
253 /// @return The start of this list.
255
256 /// Returns a reverse iterator pointing to the first element behind the start of this list.
257 /// @return The end of this list.
259
260 /// Returns a reverse iterator pointing to a constant value at the end of this list.
261 /// @return The start of this list.
263
264 /// Returns a reverse iterator pointing to the first element behind the start of this list.
265 /// @return The end of this list.
267
268
269 //################################################################################################
270 // Construction/Destruction
271 //################################################################################################
272 public:
273 /// Constructor neither requiring an allocator, nor a shared recycler.
274 /// \note
275 /// This constructor is not available if the template argument \p{TRecycling} equals
276 /// #"Recycling::Shared" and if argument \p{TAllocator}
277 /// does not equal type #"HeapAllocator".
279 #if ALIB_DEBUG_CRITICAL_SECTIONS
281 #endif
282 {}
283
284 /// Constructor that takes an initializer list, but neither a n allocator, nor a
285 /// shared recycler.
286 /// \note
287 /// This constructor is not available if the template argument \p{TRecycling} equals
288 /// #"Recycling::Shared".
289 ///
290 /// @param initList The initial lists of elements to add.
291 List(std::initializer_list<T> initList)
292 : List() { for (const auto& item : initList) push_back(item); }
293
294 /// Copy constructor.
295 /// Invokes the implementation-dependent copy constructor of recycler, copies the pointer to the
296 /// allocator and then copies each element.
297 /// @param copy The list to copy.
298 List( const List& copy)
299 : hook()
300 , recyclerType( copy )
302 ,lang::DbgCriticalSections("List")
303 #endif
304 {
305 ALIB_DCS_WITH(copy)
306 for( auto& element : copy )
307 push_back( element );
308 }
309
310 /// Move constructor.
311 /// Invokes the implementation-dependent move constructor of recycler, moves the pointer to the
312 /// allocator and then copies each element.
313 /// @param move The private recycler to move.
314 List( List&& move)
315 : hook ( std::move( move.list ) )
316 , recyclerType( std::move( move.recycler ) ) {}
317
318 /// Constructor accepting an allocator.
319 /// \note
320 /// This constructor is not available if the template argument \p{TRecycling} equals
321 /// #"Recycling::Shared" and if argument \p{TAllocator}
322 /// does not equal type #"HeapAllocator".
323 ///
324 /// @param pAllocator The allocator to use.
325 List( AllocatorType& pAllocator )
326 : hook()
327 , recyclerType( pAllocator )
329 ,lang::DbgCriticalSections("List")
330 #endif
331 {}
332
333 /// Constructor that takes an allocator and an initializer list.
334 /// \note
335 /// This constructor is not available if the template argument \p{TRecycling} equals
336 /// #"Recycling::Shared".
337 ///
338 /// @param pAllocator The allocator to use.
339 /// @param initList The initial lists of elements to add.
340 List(AllocatorType& pAllocator, std::initializer_list<T> initList)
341 : List(pAllocator) { for (const auto& item : initList) push_back(item); }
342
343 /// Constructor taking a shared recycler.
344 /// This constructor is not available if the template argument \p{TRecycling} does not equal
345 /// #"Recycling::Shared".
346 /// @param pSharedRecycler The shared recycler.
347 template<typename TSharedRecycler= SharedRecyclerType>
348 requires(!std::same_as<TSharedRecycler , void>)
349 List(TSharedRecycler& pSharedRecycler )
350 : hook()
351 , recyclerType( pSharedRecycler )
353 ,lang::DbgCriticalSections("List")
354 #endif
355 {}
356
357 /// Constructor taking a shared recycler and an initializer list.
358 /// This constructor is not available if the template argument \p{TRecycling} does not equal
359 /// #"Recycling::Shared".
360 /// @param pSharedRecycler The shared recycler.
361 /// @param initList The initial lists of elements to add.
362 template<typename TSharedRecycler= SharedRecyclerType>
363 requires(!std::same_as<TSharedRecycler , void>)
364 List(TSharedRecycler& pSharedRecycler, std::initializer_list<T> initList)
365 : List(pSharedRecycler) { for (const auto& item : initList) push_back(item); }
366
367 /// Destructor. Invokes #".Clear".
368 ~List() { if (IsNotEmpty() ) recyclerType::DisposeList( hook::first(), hook::end() ); }
369
370 //##############################################################################################
371 /// @name Allocation
372 //##############################################################################################
373 /// Returns the allocator that was passed to the constructor of this container.
374 /// @return The allocator this container uses.
376
377 /// Counts the number of currently allocated but unused (not contained) list elements
378 /// that will be recycled with upcoming insertions.
379 ///
380 /// \note
381 /// This method is provided for completeness and unit-testing. It should not be of
382 /// relevance for common usage.<br>
383 /// Furthermore, this method is not available (aka does not compile) with instantiations
384 /// that specify template parameter \p{TRecycling} as
385 /// #"Recycling::None".
386 ///
387 /// @return The number of removed and not yet recycled elements.
388 integer RecyclablesCount() const { ALIB_DCS_SHARED return recyclerType::Count(); }
389
390
391 //##############################################################################################
392 /// @name Size and Capacity
393 //##############################################################################################
394 /// Evaluates the size of the list by traversing all elements.
395 /// @return The number of elements contained in this listed.
397
398 /// Tests this container for emptiness.
399 /// @return \c true if this list is empty, \c false otherwise.
400 bool empty() const { ALIB_DCS_SHARED return hook::isEmpty(); }
401
402 /// Tests this container for emptiness.
403 /// @return \c true if this list is empty, \c false otherwise.
404 bool IsNotEmpty() const { ALIB_DCS_SHARED return !hook::isEmpty(); }
405
406 /// Invokes the destructor of all elements and empties the list.
407 /// All allocated internal elements are kept for future recycling.
409 if( IsNotEmpty() ) {
410 recyclerType::RecycleList( hook::first(), hook::end() );
411 hook::reset();
412 } }
413
414 /// Same as clear, but does not recycle internal nodes. Furthermore, all recyclables
415 /// are deleted. The latter is done only if recycling type is not
416 /// #"Recycling::Shared". In this case, the elements are still
417 /// recycled.
418 ///
419 /// This method is useful with monotonic allocators, that can be reset as well, after
420 /// this instance is reset.
422 if( IsNotEmpty() ) {
423 recyclerType::DisposeList( hook::first(), hook::end() );
424 hook::reset();
425 }
426 recyclerType::Reset();
427 }
428
429 /// Allocates the required memory for the number of additional elements expected.
430 /// @see Chapter #"alib_contmono_containers_recycling_reserving" of the Programmer's
431 /// Manual.
432 ///
433 /// @param qty The expected resulting number (or increase) of elements to be stored in
434 /// this container.
435 /// @param reference Denotes whether \p{qty} is meant as an absolute size or an
436 /// increase.
438 auto requiredRecyclables= ( qty
439 - (reference == lang::ValueReference::Absolute ? size()
440 : 0 ) )
441 - recyclerType::Count();
442
443 if( requiredRecyclables > 0 )
444 recyclerType::Reserve( requiredRecyclables );
445 }
446
447 //##############################################################################################
448 /// @name Element Access
449 //##############################################################################################
450
451 /// Traverses the list to return the item with the given \p{idx}.
452 /// (Executes in linear time <b>O(N)</b>.)
453 ///
454 /// @param idx The index of the element to retrieve.
455 /// @return A mutable reference to \p{T}.
457 ALIB_ASSERT_ERROR( !hook::isEmpty(), "MONOMEM/LIST",
458 "Reference to element requested on empty containers::List" )
459
460 Element* act= hook::first();
461 for( integer i= 0 ; i < idx ; ++i ) {
462 act= act->next();
463 ALIB_ASSERT_ERROR( act != nullptr, "MONOMEM/LIST",
464 "Element index out of bounds: {} >= {}" , idx, i )
465 }
466 return act->data;
467 }
468
469 /// Traverses the list to return the item with the given \p{idx}.
470 /// (Executes in linear time <b>O(N)</b>.)
471 /// @param idx The index of the element to retrieve.
472 /// @return A constant reference to \p{T}.
473 const T& ElementAt(integer idx) const {ALIB_DCS_SHARED
474 ALIB_ASSERT_ERROR( hook::isNotEmpty(), "MONOMEM/LIST",
475 "Reference to element requested on empty containers::List" )
476
477 Element* act= hook::first();
478 for( integer i= 0 ; i < idx ; ++i ) {
479 act= act->next();
480 ALIB_ASSERT_ERROR( act != nullptr, "MONOMEM/LIST",
481 "Element index out of bounds: {} >= {}" , idx, i )
482 }
483 return act->data;
484 }
485
486 /// Returns a non-constant reference to the first object of the list.
487 /// @return A mutable reference to \p{T}.
489 ALIB_ASSERT_ERROR( !hook::isEmpty(), "MONOMEM/LIST",
490 "Reference to element requested on empty containers::List" )
491 return hook::first()->data;
492 }
493
494
495 /// Returns a constant reference to the first object of the list.
496 /// @return A constant reference to \p{T}.
497 const T& front() const {ALIB_DCS_SHARED
498 ALIB_ASSERT_ERROR( !hook::isEmpty(), "MONOMEM/LIST",
499 "Reference to element requested on empty containers::List" )
500 return hook::first()->data;
501 }
502
503 /// Returns a non-constant reference to the last object of the list.
504 /// @return A mutable reference to \p{T}.
506 ALIB_ASSERT_ERROR( !hook::isEmpty(), "MONOMEM/LIST",
507 "Reference to element requested on empty containers::List" )
508 return hook::last()->data;
509 }
510
511 /// Returns a constant reference to the last object of the list.
512 /// @return A constant reference to \p{T}.
513 const T& back() const {ALIB_DCS_SHARED
514 ALIB_ASSERT_ERROR( hook::isNotEmpty(), "MONOMEM/LIST",
515 "Reference to element requested on empty containers::List" )
516 return hook::last()->data;
517 }
518
519 //################################################################################################
520 /// @name Element Insertion
521 //################################################################################################
522 /// Adds a new element before the given \p{position}.
523 /// @param position The position to emplace the new element.
524 /// @param copy The value to copy and insert.
525 /// @return A constant reference to the element added.
526 iterator Insert(const_iterator position, const T& copy) {ALIB_DCS
527 Element* elem= recyclerType::Get();
528 new (&elem->data) T(copy);
529 position.element->addBefore( elem );
530
531 return iterator(elem);
532 }
533
534 /// Moves a value into this container before the given \p{position}.
535 /// @param position The position to emplace the new element.
536 /// @param move The value to move into this container.
537 /// @return A constant reference to the element moved.
539 Element* elem= recyclerType::Get();
540 new (&elem->data) T(std::move(move));
541 position.element->addBefore( elem );
542
543 return iterator(elem);
544 }
545
546 /// Adds a new element at the end of the list.
547 /// @param copy The value to copy and insert.
548 /// @return A reference to the element added.
549 T& push_back(const T& copy) {ALIB_DCS
550 Element* elem= recyclerType::Get();
551
552 new (&elem->data) T(copy);
553 hook::pushEnd( elem );
554 return elem->data;
555 }
556
557 /// Moves a value to the end of this list.
558 /// @param move The value to move into this container.
559 /// @return A reference to the element moved.
560 T& push_back(T&& move) {ALIB_DCS
561 Element* elem= recyclerType::Get();
562
563 new (&elem->data) T(std::move(move));
564 hook::pushEnd( elem );
565 return elem->data;
566 }
567
568 /// Adds a new element at the start of the list.
569 /// @param copy The value to copy and insert.
570 /// @return A reference to the element added.
571 T& push_front(const T& copy) {ALIB_DCS
572 Element* elem= recyclerType::Get();
573 new (&elem->data) T(copy);
574 hook::pushFront( elem );
575 return elem->data;
576 }
577
578 /// Moves a value to the start of this list.
579 /// @param move The value to move into this container.
580 /// @return A reference to the element moved.
581 T& push_front(T&& move) {ALIB_DCS
582 Element* elem= recyclerType::Get();
583
584 new (&elem->data) T(std::move(move));
585 hook::pushFront( elem );
586 return elem->data;
587 }
588
589 /// Adds a new element before the given \p{position}.
590 /// @tparam TArgs Types of variadic parameters given with parameter \p{args}.
591 /// @param position The position to emplace the new element.
592 /// @param args Variadic parameters to be forwarded to the constructor of type \p{T}.
593 /// @return A constant reference to the element added.
594 template<typename... TArgs>
595 iterator emplace(const_iterator position, TArgs&&... args) {ALIB_DCS
596 Element* elem= recyclerType::Get();
597 new (&elem->data) T( std::forward<TArgs>(args)... );
598 position.element->addBefore( elem );
599
600 return iterator(elem);
601 }
602
603 /// Adds a new element at the end of the list.
604 /// @tparam TArgs Types of variadic parameters given with parameter \p{args}.
605 /// @param args Variadic parameters to be forwarded to the constructor of type \p{T}.
606 /// @return A reference to the element added.
607 template<typename... TArgs>
608 T& emplace_back(TArgs&&... args) {ALIB_DCS
609 Element* elem= recyclerType::Get();
610
611 new (&elem->data) T( std::forward<TArgs>(args)... );
612 hook::pushEnd( elem );
613 return elem->data;
614 }
615
616 /// Adds a new element at the end of the list.
617 /// @tparam TArgs Types of variadic parameters given with parameter \p{args}.
618 /// @param args Variadic parameters to be forwarded to the constructor of type \p{T}.
619 /// @return A reference to the element added.
620 template<typename... TArgs>
621 T& emplace_front(TArgs&&... args) {ALIB_DCS
622 Element* elem= recyclerType::Get();
623
624 new (&elem->data) T( std::forward<TArgs>(args)... );
625 hook::pushFront( elem );
626 return elem->data;
627 }
628
629 //##############################################################################################
630 /// @name Element Removal
631 //##############################################################################################
632 /// Removes an element at the given position.
633 ///
634 /// @param position A constant iterator pointing to the element to be removed.
635 /// Mutable iterators are inherently converted with the invocation of this
636 /// method.
637 /// @return A mutable iterator pointing behind the removed element.
638 /// If \p{position} refers to the last element of the list, iterator #".end()" is
639 /// returned.
641 ALIB_ASSERT_ERROR( !hook::isEmpty(), "MONOMEM/LIST",
642 "Erase requested on empty containers::List" )
643 ALIB_ASSERT_ERROR( position != end(), "MONOMEM/LIST",
644 "Iterator end() given with containers::List::erase" )
645
646
647 Element* next = position.element->next();
648 position.element->remove();
649 recyclerType::Recycle( position.element );
650
651 return iterator(next);
652 }
653
654 /// Removes a range of elements defined by iterators \p{first} and \p{last}.
655 ///
656 /// @param begin The start of the range to remove.
657 /// @param end The first element behind the range to remove.
658 /// @return A mutable iterator referring to the given \p{last}.
661 "MONOMEM/LIST", "Erase requested on empty containers::List" )
662 if( begin == end )
663 return iterator(const_cast<Element*>( end.element ));
664
665 begin.element->remove( end.element->prev() );
666 recyclerType::RecycleList( begin.element, end.element );
667
668 return iterator( end.element );
669 }
670
671 /// Removes the first element.
673 {ALIB_DCS
674 ALIB_ASSERT_ERROR( !empty(), "MONOMEM/LIST", "pop_back called on empty List instance." )
675 recyclerType::Recycle( hook::popFront() );
676 }
677
678 /// Removes the last element.
679 void pop_back()
680 {ALIB_DCS
681 ALIB_ASSERT_ERROR( !empty(), "MONOMEM/LIST", "pop_back called on empty List instance." )
682 recyclerType::Recycle( hook::popEnd() );
683 }
684
685
686}; // class List
687
688} // namespace alib[::containers]
689
690/// Type alias in namespace \b alib.
691template<typename T, Recycling TRecycling = containers::Recycling::Private>
693
694#if ALIB_MONOMEM
695/// Type alias in namespace \b alib.
696template<typename T, Recycling TRecycling = containers::Recycling::Private>
698
699/// Type alias in namespace \b alib.
700template<typename T, Recycling TRecycling = containers::Recycling::Private>
702#endif
703
704} // namespace [alib]
#define ALIB_DCS
Definition alib.inl:1466
#define ALIB_DEBUG_CRITICAL_SECTIONS
Definition alib.inl:58
#define ALIB_DCS_WITH(CS)
Definition alib.inl:1468
#define ALIB_EXPORT
Definition alib.inl:562
#define ALIB_ASSERT_ERROR(cond, domain,...)
Definition alib.inl:1144
#define ALIB_DCS_SHARED
Definition alib.inl:1467
reverse_iterator rbegin()
Definition list.inl:246
iterator Insert(const_iterator position, T &&move)
Definition list.inl:538
iterator Insert(const_iterator position, const T &copy)
Definition list.inl:526
List(const List &copy)
Definition list.inl:298
const T & ElementAt(integer idx) const
Definition list.inl:473
const_iterator cend() const
Definition list.inl:242
const_reverse_iterator crend() const
Definition list.inl:266
List(TSharedRecycler &pSharedRecycler, std::initializer_list< T > initList)
Definition list.inl:364
iterator erase(const_iterator position)
Definition list.inl:640
integer size_type
The type defining sizes of this container.
Definition list.inl:91
typename detail::RecyclingSelector< TRecycling > ::template HookType< TAllocator, detail::ListElement< T > > SharedRecyclerType
Definition list.inl:103
bool IsNotEmpty() const
Definition list.inl:404
T & push_back(T &&move)
Definition list.inl:560
AllocatorType & GetAllocator()
Definition list.inl:375
TAllocator AllocatorType
The allocator type that TAllocator specifies.
Definition list.inl:95
const_iterator cbegin() const
Definition list.inl:238
iterator erase(const_iterator begin, const_iterator end)
Definition list.inl:659
List(List &&move)
Definition list.inl:314
typename detail::RecyclingSelector< TRecycling >::template Type< TAllocator, detail::ListElement< T > > recyclerType
The recycler type.
Definition list.inl:83
List(TSharedRecycler &pSharedRecycler)
Definition list.inl:349
const_iterator end() const
Definition list.inl:234
List(std::initializer_list< T > initList)
Definition list.inl:291
integer size() const
Definition list.inl:396
std::reverse_iterator< const_iterator > const_reverse_iterator
The constant iterator exposed by this container.
Definition list.inl:212
T & push_front(const T &copy)
Definition list.inl:571
lang::BidiListHook< detail::ListElement< T > > hook
The hook type.
Definition list.inl:74
iterator emplace(const_iterator position, TArgs &&... args)
Definition list.inl:595
integer RecyclablesCount() const
Definition list.inl:388
detail::ListElement< T > Element
The list element type.
Definition list.inl:80
T & push_front(T &&move)
Definition list.inl:581
const_reverse_iterator rend() const
Definition list.inl:258
TIterator< T > iterator
The mutable iterator exposed by this container.
Definition list.inl:209
T & push_back(const T &copy)
Definition list.inl:549
void pop_back()
Removes the last element.
Definition list.inl:679
lang::AllocatorMember< TAllocator > allocBase
The type of the base class that stores the allocator.
Definition list.inl:77
const T & front() const
Definition list.inl:497
List(AllocatorType &pAllocator)
Definition list.inl:325
T value_type
Exposes template parameter T to the outer world in a std compatible way.
Definition list.inl:88
List(AllocatorType &pAllocator, std::initializer_list< T > initList)
Definition list.inl:340
reverse_iterator rend()
Definition list.inl:250
void pop_front()
Removes the first element.
Definition list.inl:672
const_reverse_iterator crbegin() const
Definition list.inl:262
bool empty() const
Definition list.inl:400
const_reverse_iterator rbegin() const
Definition list.inl:254
TIterator< const T > const_iterator
The constant iterator exposed by this container.
Definition list.inl:206
T & emplace_back(TArgs &&... args)
Definition list.inl:608
const T & back() const
Definition list.inl:513
~List()
Destructor. Invokes #".Clear".
Definition list.inl:368
const_iterator begin() const
Definition list.inl:230
T & ElementAt(integer idx)
Definition list.inl:456
void ReserveRecyclables(integer qty, lang::ValueReference reference)
Definition list.inl:437
std::reverse_iterator< iterator > reverse_iterator
The mutable iterator exposed by this container.
Definition list.inl:215
T & emplace_front(TArgs &&... args)
Definition list.inl:621
Detail namespace of module ALib Containers.
ValueReference
Denotes if a value is interpreted as an absolute or relative number.
@ Absolute
Referring to an absolute value.
containers::List< T, MonoAllocator, TRecycling > ListMA
Type alias in namespace alib.
Definition list.inl:697
lang::integer integer
Type alias in namespace alib.
Definition integers.inl:149
containers::List< T, PoolAllocator, TRecycling > ListPA
Type alias in namespace alib.
Definition list.inl:701
containers::List< T, HeapAllocator, TRecycling > List
Type alias in namespace alib.
Definition list.inl:692
TConstOrMutableElement * pointer
Implementation of std::iterator_traits.
Definition list.inl:124
TConstOrMutableElement * operator->() const
Definition list.inl:200
integer difference_type
Implementation of std::iterator_traits.
Definition list.inl:123
TConstOrMutableElement & reference
Implementation of std::iterator_traits.
Definition list.inl:125
TIterator()=default
Default constructor creating an invalid iterator.
TConstOrMutableElement & operator*() const
Definition list.inl:196
std::bidirectional_iterator_tag iterator_category
Implementation of std::iterator_traits.
Definition list.inl:121
bool operator!=(TIterator other) const
Definition list.inl:176
TIterator(const TMutable &mutableIt)
Definition list.inl:151
TConstOrMutableElement value_type
Implementation of std::iterator_traits.
Definition list.inl:122
bool operator==(TIterator other) const
Definition list.inl:171
Extents BidiNodeBase by an value of type T.
Definition list.inl:15
T data
The custom data object.
Definition list.inl:16
TAllocator & GetAllocator() const noexcept
detail::ListElement< T > * first() const noexcept
Definition bidilist.inl:198
detail::ListElement< T > * popFront() noexcept
Definition bidilist.inl:238
integer count(const TNode *end=nullptr) const noexcept
Definition bidilist.inl:255
detail::ListElement< T > * popEnd() noexcept
Definition bidilist.inl:243
void pushFront(detail::ListElement< T > *elem) noexcept
Definition bidilist.inl:219
detail::ListElement< T > * end() const noexcept
Definition bidilist.inl:191
void pushEnd(detail::ListElement< T > *elem) noexcept
Definition bidilist.inl:228
detail::ListElement< T > * last() const noexcept
Definition bidilist.inl:203
void remove() noexcept
Unhooks this node from a list.
Definition bidilist.inl:97
void addBefore(TElement *elem) noexcept
Definition bidilist.inl:80
void next(SidiNodeBase *p)
Definition sidilist.inl:93