5#include "Stroika/Foundation/Containers/Private/IteratorImplHelper.h"
17 template <qCompilerAndStdLib_Constra
intDiffersInTemplateRedeclaration_BWA (IInOrderComparer<T>) INORDER_COMPARER>
18 class SortedSet_stdset<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
51 return fData_.size ();
53 virtual bool empty ()
const override
57 return fData_.empty ();
73 auto found = fData_.find (v);
75 (
found == Debug::UncheckedDynamicCast<const IteratorRep_&> (this->inherited::Find_equal_to (v,
seq).ConstGetRep ())
76 .fIterator.GetUnderlyingIteratorRep ()));
85 return Common::EqualsComparerAdapter<T, INORDER_COMPARER>{fData_.key_comp ()};
90 return Memory::MakeSharedPtr<Rep_> (fData_.key_comp ());
96 auto result = Memory::MakeSharedPtr<Rep_> (*
this);
97 auto&
mir = Debug::UncheckedDynamicCast<const IteratorRep_&> (i->ConstGetRep ());
98 result->fData_.MoveIteratorHereAfterClone (
99 &
mir.fIterator, &fData_,
104 virtual bool Equals (
const typename Iterable<value_type>::_IRep&
rhs)
const override
107 return this->_Equals_Reference_Implementation (
rhs);
112 auto i = fData_.find (
item);
113 bool notDone = i != fData_.end ();
125 fData_.insert (
item);
126 fChangeCounts_.PerformedChange ();
132 auto i = fData_.find (
item);
133 if (i != fData_.end ()) [[
likely]] {
135 fChangeCounts_.PerformedChange ();
142 Require (
not i.AtEnd ());
144 auto&
mir = Debug::UncheckedDynamicCast<const IteratorRep_&> (i.ConstGetRep ());
145 mir.fIterator.AssertDataMatches (&fData_);
146 auto nextIResult = fData_.erase (
mir.fIterator.GetUnderlyingIteratorRep ());
147 fChangeCounts_.PerformedChange ();
148 if (
nextI !=
nullptr) {
158 return Common::ThreeWayComparerAdapter<T, INORDER_COMPARER>{fData_.key_comp ()};
162 using DataStructureImplType_ = DataStructures::STLContainerWrapper<STDSET<INORDER_COMPARER>>;
163 using IteratorRep_ = Private::IteratorImplHelper_<value_type, DataStructureImplType_>;
166 DataStructureImplType_ fData_;
175 template <
typename T>
177 requires (totally_ordered<T>)
180 AssertRepValidType_ ();
182 template <
typename T>
183 template <IInOrderComparer<T> INORDER_COMPARER>
184 inline SortedSet_stdset<T>::SortedSet_stdset (INORDER_COMPARER&& inorderComparer)
185 : inherited{Memory::MakeSharedPtr<Rep_<remove_cvref_t<INORDER_COMPARER>>> (forward<INORDER_COMPARER> (inorderComparer))}
187 AssertRepValidType_ ();
189 template <
typename T>
191 requires (totally_ordered<T>)
195 AssertRepValidType_ ();
197 template <
typename T>
198 template <IInOrderComparer<T> INORDER_COMPARER>
200 : SortedSet_stdset{forward<INORDER_COMPARER> (inOrderComparer)}
203 AssertRepValidType_ ();
205#if !qCompilerAndStdLib_RequiresNotMatchInlineOutOfLineForTemplateClassBeingDefined_Buggy
206 template <
typename T>
207 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE>
208 requires (not derived_from<remove_cvref_t<ITERABLE_OF_ADDABLE>, SortedSet_stdset<T>>)
212 this->AddAll (forward<ITERABLE_OF_ADDABLE> (src));
213 AssertRepValidType_ ();
216 template <
typename T>
217 template <IInOrderComparer<T> INORDER_COMPARER, IIterableOfTo<T> ITERABLE_OF_ADDABLE>
219 : SortedSet_stdset (forward<INORDER_COMPARER> (inOrderComparer))
222 AssertRepValidType_ ();
224 template <
typename T>
225 template <IInputIterator<T> ITERATOR_OF_ADDABLE>
230 AssertRepValidType_ ();
232 template <
typename T>
233 template <IInOrderComparer<T> INORDER_COMPARER, IInputIterator<T> ITERATOR_OF_ADDABLE>
235 : SortedSet_stdset (forward<INORDER_COMPARER> (inOrderComparer))
238 AssertRepValidType_ ();
240 template <
typename T>
241 inline void SortedSet_stdset<T>::AssertRepValidType_ ()
const
244 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)
bool Equals(const T *lhs, const T *rhs)
strcmp or wsccmp() as appropriate == 0
#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...
SortedSet_stdset<T> is an std::set-based concrete implementation of the SortedSet<T> container patter...
nonvirtual optional< value_type > Lookup(ArgByValueType< value_type > item) const
nonvirtual ElementEqualityComparerType GetElementEqualsComparer() const
nonvirtual Set CloneEmpty() const
for return Set<T> { s->GetEqualsComparer(); } - except more efficient - clones settings/dynamic subty...
nonvirtual void Remove(ArgByValueType< value_type > item)
Remove the item (given by value or iterator pointing to it) from the contain. The item MUST exist.
nonvirtual bool RemoveIf(ArgByValueType< value_type > item)
nonvirtual void Add(ArgByValueType< value_type > item)
nonvirtual void AddAll(ITERATOR_OF_ADDABLE &&start, ITERATOR_OF_ADDABLE2 &&end)
nonvirtual ElementThreeWayComparerType GetElementThreeWayComparer() const
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,...