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