Stroika Library 3.0d18
 
Loading...
Searching...
No Matches
SortedSet_stdset.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
5// Moved #includes outside #include guard to avoid deadly embrace
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <set>
10
11#include "Stroika/Foundation/Containers/SortedSet.h"
12
13#ifndef _Stroika_Foundation_Containers_Concrete_SortedSet_stdset_h_
14#define _Stroika_Foundation_Containers_Concrete_SortedSet_stdset_h_
15
16/**
17 * \file
18 *
19 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
20 */
21
23
24 using Common::IInOrderComparer;
25
26 /**
27 * \brief SortedSet_stdset<T> is an std::set-based concrete implementation of the SortedSet<T> container pattern.
28 *
29 * \note Runtime performance/complexity:
30 * Very good low overhead implementation
31 *
32 * o size () is constant complexity
33 * o Uses Memory::BlockAllocatorOrStdAllocatorAsAppropriate
34 *
35 * \note \em Thread-Safety <a href="Thread-Safety.md#C++-Standard-Thread-Safety">C++-Standard-Thread-Safety</a>
36 */
37 template <typename T>
38 class SortedSet_stdset : public SortedSet<T> {
39 private:
40 using inherited = SortedSet<T>;
41
42 public:
43 /**
44 */
45 using ElementEqualityComparerType = typename Set<T>::ElementEqualityComparerType;
46 using ElementInOrderComparerType = typename inherited::ElementInOrderComparerType;
47 using ElementThreeWayComparerType = typename inherited::ElementThreeWayComparerType;
48 using value_type = typename inherited::value_type;
49
50 public:
51 /**
52 */
53 template <IInOrderComparer<T> INORDER_COMPARER>
54 using STDSET =
55 set<value_type, INORDER_COMPARER, Memory::BlockAllocatorOrStdAllocatorAsAppropriate<value_type, sizeof (value_type) <= 1024>>;
56
57 public:
58 /**
59 * \see docs on SortedSet<> constructor
60 * \pre IInOrderComparer<INORDER_COMPARER,T> ()
61 */
63 requires (totally_ordered<T>);
64 template <IInOrderComparer<T> INORDER_COMPARER>
65 explicit SortedSet_stdset (INORDER_COMPARER&& inorderComparer);
66 SortedSet_stdset (SortedSet_stdset&&) noexcept = default;
67 SortedSet_stdset (const SortedSet_stdset&) noexcept = default;
68 SortedSet_stdset (const initializer_list<T>& src)
69 requires (totally_ordered<T>);
70 template <IInOrderComparer<T> INORDER_COMPARER>
71 SortedSet_stdset (INORDER_COMPARER&& inOrderComparer, const initializer_list<T>& src);
72 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE>
73 requires (not derived_from<remove_cvref_t<ITERABLE_OF_ADDABLE>, SortedSet_stdset<T>>)
74 explicit SortedSet_stdset (ITERABLE_OF_ADDABLE&& src)
75#if qCompilerAndStdLib_RequiresNotMatchInlineOutOfLineForTemplateClassBeingDefined_Buggy
77 {
78 this->AddAll (forward<ITERABLE_OF_ADDABLE> (src));
79 AssertRepValidType_ ();
80 }
81#endif
82 ;
83 template <IInOrderComparer<T> INORDER_COMPARER, IIterableOfTo<T> ITERABLE_OF_ADDABLE>
84 SortedSet_stdset (INORDER_COMPARER&& inOrderComparer, ITERABLE_OF_ADDABLE&& src);
85 template <IInputIterator<T> ITERATOR_OF_ADDABLE>
86 SortedSet_stdset (ITERATOR_OF_ADDABLE&& start, ITERATOR_OF_ADDABLE&& end);
87 template <IInOrderComparer<T> INORDER_COMPARER, IInputIterator<T> ITERATOR_OF_ADDABLE>
88 SortedSet_stdset (INORDER_COMPARER&& inOrderComparer, ITERATOR_OF_ADDABLE&& start, ITERATOR_OF_ADDABLE&& end);
89
90 public:
91 /**
92 */
93 nonvirtual SortedSet_stdset& operator= (SortedSet_stdset&&) noexcept = default;
94 nonvirtual SortedSet_stdset& operator= (const SortedSet_stdset&) = default;
95
96 private:
97 using IImplRepBase_ = typename SortedSet<T>::_IRep;
98 template <qCompilerAndStdLib_ConstraintDiffersInTemplateRedeclaration_BWA (IInOrderComparer<T>) INORDER_COMPARER>
99 class Rep_;
100
101 private:
102 nonvirtual void AssertRepValidType_ () const;
103 };
104
105}
106
107/*
108 ********************************************************************************
109 ******************************* Implementation Details *************************
110 ********************************************************************************
111 */
112#include "SortedSet_stdset.inl"
113
114#endif /*_Stroika_Foundation_Containers_Concrete_SortedSet_stdset_h_ */
conditional_t< qStroika_Foundation_Memory_PreferBlockAllocation and andTrueCheck, BlockAllocator< T >, std::allocator< T > > BlockAllocatorOrStdAllocatorAsAppropriate
for type T, either use BlockAllocator<T>, or std::allocator
SortedSet_stdset<T> is an std::set-based concrete implementation of the SortedSet<T> container patter...
nonvirtual void AddAll(ITERATOR_OF_ADDABLE &&start, ITERATOR_OF_ADDABLE2 &&end)
Implementation detail for SortedSet<T> implementors.
Definition SortedSet.h:204
static constexpr default_sentinel_t end() noexcept
Support for ranged for, and STL syntax in general.