5#include "Stroika/Foundation/Containers/Private/IteratorImplHelper.h"
17 template <qCompilerAndStdLib_Constra
intDiffersInTemplateRedeclaration_BWA (Common::IInOrderComparer<T>) INORDER_COMPARER>
18 class SortedCollection_stdmultiset<T>::Rep_ :
public IImplRepBase_,
public Memory::UseBlockAllocationIfAppropriate<Rep_<INORDER_COMPARER>> {
20 using inherited = IImplRepBase_;
30 Rep_ (
const Rep_&
from) =
default;
33 nonvirtual Rep_& operator= (
const Rep_&) =
delete;
40 return Memory::MakeSharedPtr<Rep_> (*
this);
47 virtual size_t size ()
const override
50 return fData_.size ();
52 virtual bool empty ()
const override
55 return fData_.empty ();
74 auto found = fData_.lower_bound (v);
75 if (
found != fData_.end ()
and (fData_.key_comp () (v, *
found)
or fData_.key_comp () (*
found, v))) {
76 found = fData_.end ();
79 (
found == Debug::UncheckedDynamicCast<const IteratorRep_&> (this->inherited::Find_equal_to (v,
seq).ConstGetRep ())
80 .fIterator.GetUnderlyingIteratorRep ()));
88 return Memory::MakeSharedPtr<Rep_> (fData_.key_comp ());
94 auto result = Memory::MakeSharedPtr<Rep_> (*
this);
95 auto&
mir = Debug::UncheckedDynamicCast<const IteratorRep_&> (i->ConstGetRep ());
96 result->fData_.MoveIteratorHereAfterClone (
97 &
mir.fIterator, &fData_,
102#if qCompilerAndStdLib_MemoryInsertAt_Buggy
105 [[gnu::noinline, gnu::optimize (
"O0")]]
114 fChangeCounts_.PerformedChange ();
118 fChangeCounts_.PerformedChange ();
125 auto nextIR = fData_.erase (Debug::UncheckedDynamicCast<const IteratorRep_&> (i.ConstGetRep ()).fIterator.GetUnderlyingIteratorRep ());
127 fChangeCounts_.PerformedChange ();
128 if (
nextI !=
nullptr) {
135 auto&
mir = Debug::UncheckedDynamicCast<const IteratorRep_&> (i.ConstGetRep ());
136 mir.fIterator.AssertDataMatches (&fData_);
137 auto nextIR = fData_.erase (
mir.fIterator.GetUnderlyingIteratorRep ());
138 fChangeCounts_.PerformedChange ();
139 if (
nextI !=
nullptr) {
149 return Common::ThreeWayComparerAdapter<T, INORDER_COMPARER>{fData_.key_comp ()};
154 return fData_.contains (
item);
160 auto i = fData_.find (
item);
161 if (i != fData_.end ()) {
163 fChangeCounts_.PerformedChange ();
168 using DataStructureImplType_ = DataStructures::STLContainerWrapper<STDMULTISET<INORDER_COMPARER>>;
169 using IteratorRep_ = Private::IteratorImplHelper_<value_type, DataStructureImplType_>;
172 DataStructureImplType_ fData_;
181 template <
typename T>
185 AssertRepValidType_ ();
187 template <
typename T>
188 template <Common::IInOrderComparer<T> INORDER_COMPARER>
189 inline SortedCollection_stdmultiset<T>::SortedCollection_stdmultiset (INORDER_COMPARER&& inorderComparer)
190 : inherited{Memory::MakeSharedPtr<Rep_<remove_cvref_t<INORDER_COMPARER>>> (inorderComparer)}
192 AssertRepValidType_ ();
194 template <
typename T>
196 : SortedCollection_stdmultiset{}
199 AssertRepValidType_ ();
201 template <
typename T>
202 template <Common::IInOrderComparer<T> INORDER_COMPARER>
204 : SortedCollection_stdmultiset{forward<INORDER_COMPARER> (inOrderComparer)}
207 AssertRepValidType_ ();
209#if !qCompilerAndStdLib_RequiresNotMatchInlineOutOfLineForTemplateClassBeingDefined_Buggy
210 template <
typename T>
211 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE>
212 requires (not derived_from<remove_cvref_t<ITERABLE_OF_ADDABLE>, SortedCollection_stdmultiset<T>>)
214 : SortedCollection_stdmultiset{}
216 this->AddAll (forward<ITERABLE_OF_ADDABLE> (src));
217 AssertRepValidType_ ();
220 template <
typename T>
221 template <Common::IInOrderComparer<T> INORDER_COMPARER, IIterableOfTo<T> ITERABLE_OF_ADDABLE>
223 : SortedCollection_stdmultiset{forward<INORDER_COMPARER> (inOrderComparer)}
226 AssertRepValidType_ ();
228 template <
typename T>
229 template <IInputIterator<T> ITERATOR_OF_ADDABLE>
231 : SortedCollection_stdmultiset{}
234 AssertRepValidType_ ();
236 template <
typename T>
237 template <Common::IInOrderComparer<T> INORDER_COMPARER, IInputIterator<T> ITERATOR_OF_ADDABLE>
239 ITERATOR_OF_ADDABLE&& end)
240 : SortedCollection_stdmultiset{forward<INORDER_COMPARER> (inOrderComparer)}
243 AssertRepValidType_ ();
245 template <
typename T>
246 inline void SortedCollection_stdmultiset<T>::AssertRepValidType_ ()
const
249 typename inherited::template _SafeReadRepAccessor<IImplRepBase_> tmp{
this};
#define qStroika_Foundation_Debug_AssertionsChecked
The qStroika_Foundation_Debug_AssertionsChecked flag determines if assertions are checked and validat...
#define RequireNotNull(p)
#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...
nonvirtual void AddAll(ITERATOR_OF_ADDABLE &&start, ITERATOR_OF_ADDABLE2 &&end)
nonvirtual void Update(const Iterator< value_type > &i, ArgByValueType< value_type > newValue, Iterator< value_type > *nextI=nullptr)
nonvirtual void Add(ArgByValueType< value_type > item)
SortedCollection_stdmultiset<T> is an stdmultiset-based concrete implementation of the SortedCollecti...
SortedCollection_stdmultiset()
nonvirtual ElementThreeWayComparerType GetElementThreeWayComparer() const
nonvirtual bool Contains(ArgByValueType< T > item) const
Compares items with the already associated GetInOrderComparer(), and returns true if the item is foun...
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'.
SequencePolicy
equivalent which of 4 types being used std::execution::sequenced_policy, parallel_policy,...