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 ();
70 auto found = fData_.find (v);
72 (
found == Debug::UncheckedDynamicCast<const IteratorRep_&> (this->inherited::Find_equal_to (v,
seq).ConstGetRep ())
73 .fIterator.GetUnderlyingIteratorRep ()));
81 return Memory::MakeSharedPtr<Rep_> (fData_.key_comp ());
87 auto result = Memory::MakeSharedPtr<Rep_> (*
this);
88 auto&
mir = Debug::UncheckedDynamicCast<const IteratorRep_&> (i->ConstGetRep ());
89 result->fData_.MoveIteratorHereAfterClone (
90 &
mir.fIterator, &fData_,
99 fChangeCounts_.PerformedChange ();
107 auto nextIR = fData_.erase (Debug::UncheckedDynamicCast<const IteratorRep_&> (i.ConstGetRep ()).fIterator.GetUnderlyingIteratorRep ());
109 fChangeCounts_.PerformedChange ();
110 if (
nextI !=
nullptr) {
117 auto&
mir = Debug::UncheckedDynamicCast<const IteratorRep_&> (i.ConstGetRep ());
118 mir.fIterator.AssertDataMatches (&fData_);
119 auto nextIR = fData_.erase (
mir.fIterator.GetUnderlyingIteratorRep ());
120 fChangeCounts_.PerformedChange ();
121 if (
nextI !=
nullptr) {
131 return Common::ThreeWayComparerAdapter<T, INORDER_COMPARER>{fData_.key_comp ()};
136 return fData_.contains (
item);
142 auto i = fData_.find (
item);
143 if (i != fData_.end ()) {
145 fChangeCounts_.PerformedChange ();
150 using DataStructureImplType_ = DataStructures::STLContainerWrapper<STDMULTISET<INORDER_COMPARER>>;
151 using IteratorRep_ = Private::IteratorImplHelper_<value_type, DataStructureImplType_>;
154 DataStructureImplType_ fData_;
163 template <
typename T>
167 AssertRepValidType_ ();
169 template <
typename T>
170 template <Common::IInOrderComparer<T> INORDER_COMPARER>
171 inline SortedCollection_stdmultiset<T>::SortedCollection_stdmultiset (INORDER_COMPARER&& inorderComparer)
172 : inherited{Memory::MakeSharedPtr<Rep_<remove_cvref_t<INORDER_COMPARER>>> (inorderComparer)}
174 AssertRepValidType_ ();
176 template <
typename T>
178 : SortedCollection_stdmultiset{}
181 AssertRepValidType_ ();
183 template <
typename T>
184 template <Common::IInOrderComparer<T> INORDER_COMPARER>
186 : SortedCollection_stdmultiset{forward<INORDER_COMPARER> (inOrderComparer)}
189 AssertRepValidType_ ();
191#if !qCompilerAndStdLib_RequiresNotMatchInlineOutOfLineForTemplateClassBeingDefined_Buggy
192 template <
typename T>
193 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE>
194 requires (not derived_from<remove_cvref_t<ITERABLE_OF_ADDABLE>, SortedCollection_stdmultiset<T>>)
196 : SortedCollection_stdmultiset{}
198 this->AddAll (forward<ITERABLE_OF_ADDABLE> (src));
199 AssertRepValidType_ ();
202 template <
typename T>
203 template <Common::IInOrderComparer<T> INORDER_COMPARER, IIterableOfTo<T> ITERABLE_OF_ADDABLE>
205 : SortedCollection_stdmultiset{forward<INORDER_COMPARER> (inOrderComparer)}
208 AssertRepValidType_ ();
210 template <
typename T>
211 template <IInputIterator<T> ITERATOR_OF_ADDABLE>
213 : SortedCollection_stdmultiset{}
216 AssertRepValidType_ ();
218 template <
typename T>
219 template <Common::IInOrderComparer<T> INORDER_COMPARER, IInputIterator<T> ITERATOR_OF_ADDABLE>
221 ITERATOR_OF_ADDABLE&& end)
222 : SortedCollection_stdmultiset{forward<INORDER_COMPARER> (inOrderComparer)}
225 AssertRepValidType_ ();
227 template <
typename T>
228 inline void SortedCollection_stdmultiset<T>::AssertRepValidType_ ()
const
231 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...
shared_lock< const AssertExternallySynchronizedMutex > ReadContext
Instantiate AssertExternallySynchronizedMutex::ReadContext to designate an area of code where protect...
unique_lock< AssertExternallySynchronizedMutex > WriteContext
Instantiate AssertExternallySynchronizedMutex::WriteContext to designate an area of code where protec...
nonvirtual void Apply(const function< void(ArgByValueType< T > item)> &doToElement, Execution::SequencePolicy seq=Execution::SequencePolicy::eDEFAULT) const
Run the argument function (or lambda) on each element of the container.
nonvirtual Iterator< T > Find(THAT_FUNCTION &&that, Execution::SequencePolicy seq=Execution::SequencePolicy::eDEFAULT) const
Run the argument bool-returning function (or lambda) on each element 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 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,...