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