4#include "Stroika/Foundation/Containers/DataStructures/Array.h"
6#include "Stroika/Foundation/Containers/Private/IteratorImplHelper.h"
13 class Queue_Array<T>::Rep_ :
public Queue<T>::_IRep,
public Memory::UseBlockAllocationIfAppropriate<Rep_> {
15 using inherited =
typename Queue<T>::_IRep;
19 Rep_ (
const Rep_&
from) =
default;
22 nonvirtual Rep_& operator= (
const Rep_&) =
delete;
29 return Memory::MakeSharedPtr<Rep_> (*
this);
44 virtual size_t size ()
const override
47 return fData_.size ();
49 virtual bool empty ()
const override
52 return fData_.empty ();
63 if (
auto i = fData_.Find (
that)) {
73 return Memory::MakeSharedPtr<Rep_> ();
78 fData_.push_back (
item);
79 fChangeCounts_.PerformedChange ();
84 T
item = fData_.GetAt (0);
86 fChangeCounts_.PerformedChange ();
92 if (fData_.empty ()) {
95 T
item = fData_.GetAt (0);
97 fChangeCounts_.PerformedChange ();
100 virtual value_type
Head ()
const override
103 return fData_.GetAt (0);
108 if (fData_.empty ()) {
111 return fData_.GetAt (0);
115 using DataStructureImplType_ = DataStructures::Array<value_type>;
116 using IteratorRep_ = Private::IteratorImplHelper_<value_type, DataStructureImplType_>;
119 DataStructureImplType_ fData_;
128 template <
typename T>
130 :
inherited{Memory::MakeSharedPtr<Rep_> ()}
132 AssertRepValidType_ ();
134 template <
typename T>
140 AssertRepValidType_ ();
142#if !qCompilerAndStdLib_RequiresNotMatchInlineOutOfLineForTemplateClassBeingDefined_Buggy
143 template <
typename T>
144 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE>
145 requires (not derived_from<remove_cvref_t<ITERABLE_OF_ADDABLE>, Queue_Array<T>>)
150 this->reserve (src.size ());
152 AddAllToTail (forward<ITERABLE_OF_ADDABLE> (src));
153 AssertRepValidType_ ();
156 template <
typename T>
157 template <IInputIterator<T> ITERATOR_OF_ADDABLE>
167 AssertRepValidType_ ();
169 template <
typename T>
170 inline void Queue_Array<T>::AssertRepValidType_ ()
const
173 typename inherited::template _SafeReadRepAccessor<Rep_> tmp{
this};
#define qStroika_Foundation_Debug_AssertionsChecked
The qStroika_Foundation_Debug_AssertionsChecked flag determines if assertions are checked and validat...
#define qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCFORCE
[[msvc::no_unique_address]] isn't always broken in MSVC. Annotate with this on things where its not b...
Queue_Array<T> is an Array-based concrete implementation of the Queue<T> container pattern.
nonvirtual void reserve(size_t slotsAlloced)
nonvirtual value_type Head() const
nonvirtual void AddAllToTail(ITERABLE_OF_ADDABLE &&s)
nonvirtual optional< value_type > RemoveHeadIf()
nonvirtual value_type RemoveHead()
nonvirtual void AddTail(ArgByValueType< value_type > item)
unique_lock< AssertExternallySynchronizedChecker > WriteContext
Instantiate AssertExternallySynchronizedChecker::WriteContext to designate an area of code where prot...
shared_lock< const AssertExternallySynchronizedChecker > ReadContext
Instantiate AssertExternallySynchronizedChecker::ReadContext to designate an area of code where prote...
nonvirtual Iterator< T > Find(THAT_FUNCTION &&that) const
Run the argument bool-returning function (or lambda) on the elements of the container,...
nonvirtual CONTAINER_OF_T As(CONTAINER_OF_T_CONSTRUCTOR_ARGS... args) const
nonvirtual size_t size() const
Returns the number of items contained.
nonvirtual void Apply(const function< void(ArgByValueType< T > item)> &doToElement) const
Run the argument function (or lambda) on each element of the container.
nonvirtual bool empty() const
Returns true iff size() == 0.
static constexpr default_sentinel_t end() noexcept
Support for ranged for, and STL syntax in general.
nonvirtual Iterator< T > MakeIterator() const
Create an iterator object which can be used to traverse the 'Iterable'.
Concept checks if the given type T has a const size() method which can be called to return a size_t.
SequencePolicy
equivalent which of 4 types being used std::execution::sequenced_policy, parallel_policy,...