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