4#ifndef _Stroika_Foundation_Containers_MultiSet_h_
5#define _Stroika_Foundation_Containers_MultiSet_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
11#include "Stroika/Foundation/Common/Common.h"
13#include "Stroika/Foundation/Common/Concepts.h"
14#include "Stroika/Foundation/Common/CountedValue.h"
18#include "Stroika/Foundation/Containers/Common.h"
19#include "Stroika/Foundation/Containers/DefaultTraits/MultiSet.h"
52 using Common::CountedValue;
53 using Common::IEqualsComparer;
54 using Traversal::IInputIterator;
55 using Traversal::IIterableOfTo;
56 using Traversal::Iterable;
57 using Traversal::Iterator;
112 template <
typename T,
typename TRAITS = DefaultTraits::MultiSet<T>>
141 using CounterType =
typename TraitsType::CounterType;
194 template <IEqualsComparer<T> EQUALS_COMPARER>
200 template <IEqualsComparer<T> EQUALS_COMPARER>
203 template <IEqualsComparer<T> EQUALS_COMPARER>
208#if qCompilerAndStdLib_RequiresNotMatchInlineOutOfLineForTemplateClassBeingDefined_Buggy
212 _AssertRepValidType ();
216 template <IEqualsComparer<T> EQUALS_COMPARER, IIterableOfTo<
typename TRAITS::CountedValueType> ITERABLE_OF_ADDABLE>
218 template <IInputIterator<
typename TRAITS::CountedValueType> ITERATOR_OF_ADDABLE, sentinel_for<remove_cvref_t<ITERATOR_OF_ADDABLE>> ITERATOR_OF_ADDABLE2>
221 template <IEqualsComparer<T> EQUALS_COMPARER, IInputIterator<
typename TRAITS::CountedValueType> ITERATOR_OF_ADDABLE, sentinel_for<remove_cvref_t<ITERATOR_OF_ADDABLE>> ITERATOR_OF_ADDABLE2>
225 explicit MultiSet (shared_ptr<_IRep>&& rep)
noexcept;
226 explicit MultiSet (
const shared_ptr<_IRep>& rep)
noexcept;
243 nonvirtual
void Add (ArgByValueType<T>
item);
244 nonvirtual
void Add (ArgByValueType<T>
item, CounterType
count);
279 nonvirtual
void Remove (ArgByValueType<T>
item, CounterType
count = 1);
350 nonvirtual
void clear ();
458 nonvirtual
MultiSet& operator+= (ArgByValueType<T>
item);
489 nonvirtual
void _AssertRepValidType ()
const;
500 using CounterType =
typename MultiSet::CounterType;
507 virtual shared_ptr<_IRep> CloneEmpty ()
const = 0;
509 virtual bool Equals (
const _IRep&
rhs)
const = 0;
525 nonvirtual
bool _Equals_Reference_Implementation (
const _IRep&
rhs)
const;
535#include "MultiSet.inl"
nonvirtual void AddAll(ITERATOR_OF_ADDABLE &&start, ITERATOR_OF_ADDABLE2 &&end)
nonvirtual CounterType TotalOccurrences() const
nonvirtual Iterator< value_type > erase(const Iterator< value_type > &i)
nonvirtual void Remove(ArgByValueType< T > item, CounterType count=1)
remove the argument data from the multiset. The data specified MUST exist (require) - else use Remove...
nonvirtual Iterable< T > Elements() const
nonvirtual void UpdateCount(const Iterator< value_type > &i, CounterType newCount, Iterator< value_type > *nextI=nullptr)
nonvirtual void Add(ArgByValueType< T > item)
nonvirtual Iterable< T > TopElements() const
Find the most commonly occurring elements of the multiset (list of elements - without count - ordered...
nonvirtual ElementEqualityComparerType GetElementEqualsComparer() const
typename inherited::value_type value_type
nonvirtual RESULT_CONTAINER Map(ELEMENT_MAPPER &&elementMapper) const
'override' Iterable<>::Map () function so RESULT_CONTAINER defaults to MultiSet, and improve that cas...
nonvirtual Iterable< typename TRAITS::CountedValueType > Top() const
Find the most commonly occurring elements of the multiset (list with count ordered most to last)
nonvirtual tuple< _IRep *, Iterator< value_type > > _GetWritableRepAndPatchAssociatedIterator(const Iterator< value_type > &i)
Utility to get WRITABLE underlying shared_ptr (replacement for what we normally do - _SafeReadWriteRe...
nonvirtual RESULT_CONTAINER Where(INCLUDE_PREDICATE &&includeIfTrue) const
T MultiSetOfElementType
MultiSetOfElementType is just a handy copy of the T template type which this MultiSet<T,...
nonvirtual bool Contains(ArgByValueType< T > item) const
nonvirtual void RemoveAll()
RemoveAll removes all, or all matching (predicate, iterator range, equals comparer or whatever) items...
nonvirtual CounterType OccurrencesOf(ArgByValueType< T > item) const
nonvirtual size_t RemoveIf(ArgByValueType< T > item, CounterType count=1)
remove the argument data from the multiset (can specify remove of more than are present) - returns nu...
nonvirtual void SetCount(ArgByValueType< T > i, CounterType newCount)
nonvirtual Iterable< T > UniqueElements() const
Implementation detail for iterator implementors.
Iterable<T> is a base class for containers which easily produce an Iterator<T> to traverse them.
nonvirtual CONTAINER_OF_T As(CONTAINER_OF_T_CONSTRUCTOR_ARGS... args) const
T value_type
value_type is an alias for the type iterated over - like vector<T>::value_type
static constexpr default_sentinel_t end() noexcept
Support for ranged for, and STL syntax in general.
An Iterator<T> is a copyable object which allows traversing the contents of some container....
conditional_t<(sizeof(CHECK_T)<=2 *sizeof(void *)) and is_trivially_copyable_v< CHECK_T >, CHECK_T, const CHECK_T & > ArgByValueType
This is an alias for 'T' - but how we want to pass it on stack as formal parameter.