5#include "Stroika/Foundation/Common/Concepts.h"
7#include "Stroika/Foundation/Containers/Private/IterableUtils.h"
19 :
inherited{Factory::Queue_Factory<T>::Default () ()}
21 _AssertRepValidType ();
28 _AssertRepValidType ();
30#if !qCompilerAndStdLib_RequiresNotMatchInlineOutOfLineForTemplateClassBeingDefined_Buggy
32 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE>
33 requires (not derived_from<remove_cvref_t<ITERABLE_OF_ADDABLE>, Queue<T>>)
37 AddAllToTail (forward<ITERABLE_OF_ADDABLE> (src));
38 _AssertRepValidType ();
45 _AssertRepValidType ();
52 _AssertRepValidType ();
55 template <IInputIterator<T> ITERATOR_OF_ADDABLE>
56 inline Queue<T>::Queue (ITERATOR_OF_ADDABLE&& start, ITERATOR_OF_ADDABLE&& end)
60 _AssertRepValidType ();
65 _SafeReadWriteRepAccessor<_IRep>{
this}._GetWriteableRep ().AddTail (item);
75 return _SafeReadRepAccessor<_IRep>{
this}._ConstGetRep ().Head ();
85 return _SafeReadRepAccessor<_IRep>{
this}._ConstGetRep ().HeadIf ();
90 Require (not this->empty ());
91 return _SafeReadWriteRepAccessor<_IRep>{
this}._GetWriteableRep ().RemoveHead ();
101 return _SafeReadWriteRepAccessor<_IRep>{
this}._GetWriteableRep ().RemoveHeadIf ();
103 template <
typename T>
106 _SafeReadWriteRepAccessor<_IRep>{
this}._GetWriteableRep ().AddTail (item);
108 template <
typename T>
111 Require (not this->empty ());
112 return _SafeReadWriteRepAccessor<_IRep>{
this}._GetWriteableRep ().RemoveHead ();
114 template <
typename T>
115 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE>
118 _SafeReadWriteRepAccessor<_IRep> tmp{
this};
119 for (
const auto& i : s) {
120 tmp._GetWriteableRep ().AddTail (i);
123 template <
typename T>
124 template <IInputIterator<T> ITERATOR_OF_ADDABLE>
127 _SafeReadWriteRepAccessor<_IRep> tmp{
this};
128 for (
auto i = forward<ITERATOR_OF_ADDABLE> (start); i != forward<ITERATOR_OF_ADDABLE> (end); ++i) {
129 tmp._GetWriteableRep ().AddTail (*i);
132 template <
typename T>
135 _SafeReadRepAccessor<_IRep> tmp{
this};
136 if (not tmp._ConstGetRep ().empty ()) {
137 this->_fRep = tmp._ConstGetRep ().CloneEmpty ();
140 template <
typename T>
145 template <
typename T>
149 _SafeReadRepAccessor<_IRep>{
this};
152 template <
typename T>
154 requires (equality_comparable<T>)
158 template <
typename T>
160 requires (three_way_comparable<T>)
162 return ThreeWayComparer<>{}(*
this, rhs);
#define qStroika_Foundation_Debug_AssertionsChecked
The qStroika_Foundation_Debug_AssertionsChecked flag determines if assertions are checked and validat...
#define RequireNotNull(p)
#define RequireExpression(c)
A Queue is a first-in-first-out (FIFO) data structure, where elements are arranged in well-ordered fa...
nonvirtual value_type Head() const
nonvirtual bool operator==(const Queue &rhs) const
nonvirtual T front() const
nonvirtual void AddAllToTail(ITERABLE_OF_ADDABLE &&s)
nonvirtual void push_back(ArgByValueType< value_type > item)
Add the given item to the end of the Q, so it will be removed last of all the items currently in the ...
nonvirtual void RemoveAll()
nonvirtual value_type Dequeue()
Alias for RemoveHead () - remove item from the head of the Q (line).
nonvirtual optional< value_type > RemoveHeadIf()
nonvirtual auto operator<=>(const Queue &rhs) const
typename inherited::value_type value_type
typename Iterable< T >::template SequentialEqualsComparer< T_EQUALS_COMPARER > EqualsComparer
Simply indirect to @Iterable<T>::SequentialEqualsComparer.
nonvirtual value_type RemoveHead()
nonvirtual void Enqueue(ArgByValueType< value_type > item)
add item to the end of the Q (line).
nonvirtual void AddTail(ArgByValueType< value_type > item)
nonvirtual void clear()
STL-ish alias for RemoveAll ().
nonvirtual value_type pop_back()
Iterable<T> is a base class for containers which easily produce an Iterator<T> to traverse them.
static constexpr default_sentinel_t end() noexcept
Support for ranged for, and STL syntax in general.