Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
KeyedCollection_Array.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
5// @todo fix - this SB inside ifndef but fails to compile - debug!!!
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include "Stroika/Foundation/Containers/KeyedCollection.h"
11
12#ifndef _Stroika_Foundation_Containers_Concrete_KeyedCollection_Array_h_
13#define _Stroika_Foundation_Containers_Concrete_KeyedCollection_Array_h_
14
15/**
16 * \file
17 *
18 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
19 *
20 */
21
23
24 template <typename T, typename KEY_TYPE, typename TRAITS>
25 class KeyedCollection;
26
27}
28
30
31 /**
32 * \brief KeyedCollection_Array<T> is an Array-based concrete implementation of the KeyedCollection<T> container pattern.
33 *
34 * \note Runtime performance/complexity:
35 * o performance good only if KeyedCollection remains small (probably < 10)
36 *
37 * \todo Consider overloading AddAll() to do a reserve if argument size known (so no need to 'performance fix' constructors that call AddAll todo this)
38 * maybe no need (document that if I decide so), since performance of this only decent if size small, so then no matter.
39 *
40 * \note \em Thread-Safety <a href="Thread-Safety.md#C++-Standard-Thread-Safety">C++-Standard-Thread-Safety</a>
41 */
42 template <typename T, typename KEY_TYPE, typename TRAITS = KeyedCollection_DefaultTraits<T, KEY_TYPE>>
44 : public Private::ArrayBasedContainer<KeyedCollection_Array<T, KEY_TYPE, TRAITS>, KeyedCollection<T, KEY_TYPE, TRAITS>, true> {
45 private:
47
48 public:
49 using TraitsType = typename inherited::TraitsType;
50 using KeyExtractorType = typename inherited::KeyExtractorType;
51 using KeyEqualityComparerType = typename inherited::KeyEqualityComparerType;
52 using KeyType = typename inherited::KeyType;
53 using value_type = typename inherited::value_type;
54
55 public:
56 /**
57 * \see docs on KeyedCollection<> constructor
58 */
59 template <IEqualsComparer<KEY_TYPE> KEY_EQUALS_COMPARER = equal_to<KEY_TYPE>>
60 KeyedCollection_Array (KEY_EQUALS_COMPARER&& keyComparer = KEY_EQUALS_COMPARER{})
62 KeyedCollection_Array (KeyedCollection_Array&&) noexcept = default;
63 KeyedCollection_Array (const KeyedCollection_Array&) noexcept = default;
64 template <IEqualsComparer<KEY_TYPE> KEY_EQUALS_COMPARER = equal_to<KEY_TYPE>>
65 KeyedCollection_Array (const KeyExtractorType& keyExtractor, KEY_EQUALS_COMPARER&& keyComparer = KEY_EQUALS_COMPARER{});
66 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE, IEqualsComparer<KEY_TYPE> KEY_EQUALS_COMPARER = equal_to<KEY_TYPE>>
68 not derived_from<remove_cvref_t<ITERABLE_OF_ADDABLE>, KeyedCollection_Array<T, KEY_TYPE, TRAITS>>)
69 KeyedCollection_Array (ITERABLE_OF_ADDABLE&& src)
70#if qCompilerAndStdLib_RequiresNotMatchInlineOutOfLineForTemplateClassBeingDefined_Buggy
71 : KeyedCollection_Array{KeyExtractorType{}, equal_to<KEY_TYPE>{}}
72 {
73 this->AddAll (src);
74 AssertRepValidType_ ();
75 }
76#endif
77 ;
78 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE, IEqualsComparer<KEY_TYPE> KEY_EQUALS_COMPARER = equal_to<KEY_TYPE>>
79 KeyedCollection_Array (KEY_EQUALS_COMPARER&& keyComparer, ITERABLE_OF_ADDABLE&& src)
81 template <IEqualsComparer<KEY_TYPE> KEY_EQUALS_COMPARER, IIterableOfTo<T> ITERABLE_OF_ADDABLE>
82 KeyedCollection_Array (const KeyExtractorType& keyExtractor, KEY_EQUALS_COMPARER&& keyComparer, ITERABLE_OF_ADDABLE&& src);
83 template <IInputIterator<T> ITERATOR_OF_ADDABLE, IEqualsComparer<KEY_TYPE> KEY_EQUALS_COMPARER = equal_to<KEY_TYPE>>
84 KeyedCollection_Array (ITERATOR_OF_ADDABLE&& start, ITERATOR_OF_ADDABLE&& end)
86 template <IInputIterator<T> ITERATOR_OF_ADDABLE, IEqualsComparer<KEY_TYPE> KEY_EQUALS_COMPARER = equal_to<KEY_TYPE>>
87 KeyedCollection_Array (KEY_EQUALS_COMPARER&& keyComparer, ITERATOR_OF_ADDABLE&& start, ITERATOR_OF_ADDABLE&& end)
89 template <IEqualsComparer<KEY_TYPE> KEY_EQUALS_COMPARER, IInputIterator<T> ITERATOR_OF_ADDABLE>
90 KeyedCollection_Array (const KeyExtractorType& keyExtractor, KEY_EQUALS_COMPARER&& keyComparer, ITERATOR_OF_ADDABLE&& start,
91 ITERATOR_OF_ADDABLE&& end);
92
93 public:
94 nonvirtual KeyedCollection_Array& operator= (KeyedCollection_Array&&) noexcept = default;
95 nonvirtual KeyedCollection_Array& operator= (const KeyedCollection_Array&) = default;
96
97 private:
99 template <qCompilerAndStdLib_ConstraintDiffersInTemplateRedeclaration_BWA (IEqualsComparer<KEY_TYPE>) KEY_EQUALS_COMPARER>
100 class Rep_;
101
102 private:
103 nonvirtual void AssertRepValidType_ () const;
104
105 private:
106 friend inherited;
107 };
108
109}
110
111/*
112 ********************************************************************************
113 ******************************* Implementation Details *************************
114 ********************************************************************************
115 */
116#include "KeyedCollection_Array.inl"
117
118#endif /*_Stroika_Foundation_Containers_Concrete_KeyedCollection_Array_h_ */
KeyedCollection_Array<T> is an Array-based concrete implementation of the KeyedCollection<T> containe...
a cross between Mapping<KEY, T> and Collection<T> and Set<T>
ArrayBasedContainer is a Stroika implementation detail, but its public methods are fair game and full...
impl detail for array based container support (see ArrayBasedContainer docs on bool USING_IREP)