Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Collection_Array.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Containers_Concrete_Collection_Array_h_
5#define _Stroika_Foundation_Containers_Concrete_Collection_Array_h_
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include "Stroika/Foundation/Containers/Collection.h"
11
12/**
13 * \file
14 *
15 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
16 */
17
19
20 /**
21 * \brief Collection_Array<T> is an Array-based concrete implementation of the Collection<T> container pattern.
22 *
23 * \note Runtime performance/complexity:
24 * A good low overhead, fast implementation. Adds and removes by iterator from the middle of the collection are slow.
25 * And adds are generally fast, but occasionally (on realloc) very slow once.
26 *
27 * o size () is constant complexity
28 *
29 * \note \em Thread-Safety <a href="Thread-Safety.md#C++-Standard-Thread-Safety">C++-Standard-Thread-Safety</a>
30 */
31 template <typename T>
32 class Collection_Array : public Private::ArrayBasedContainer<Collection_Array<T>, Collection<T>, false> {
33 private:
35
36 public:
37 using value_type = typename inherited::value_type;
38
39 public:
40 /**
41 * \see docs on Collection<T> constructor
42 */
44 Collection_Array (Collection_Array&&) noexcept = default;
45 Collection_Array (const Collection_Array&) noexcept = default;
46 Collection_Array (const initializer_list<value_type>& src);
47
48 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE>
49 requires (not derived_from<remove_cvref_t<ITERABLE_OF_ADDABLE>, Collection_Array<T>>)
50 Collection_Array (ITERABLE_OF_ADDABLE&& src)
51#if qCompilerAndStdLib_RequiresNotMatchInlineOutOfLineForTemplateClassBeingDefined_Buggy
53 {
54 this->reserve (src.size ());
55 this->AddAll (forward<ITERABLE_OF_ADDABLE> (src));
56 AssertRepValidType_ ();
57 }
58#endif
59 ;
60 template <IInputIterator<T> ITERATOR_OF_ADDABLE>
61 Collection_Array (ITERATOR_OF_ADDABLE&& start, ITERATOR_OF_ADDABLE&& end);
62
63 public:
64 nonvirtual Collection_Array& operator= (Collection_Array&&) noexcept = default;
65 nonvirtual Collection_Array& operator= (const Collection_Array&) = default;
66
67 private:
68 using IImplRep_ = typename Collection<T>::_IRep;
69 class Rep_;
70
71 private:
72 nonvirtual void AssertRepValidType_ () const;
73 };
74
75}
76
77/*
78 ********************************************************************************
79 ******************************* Implementation Details *************************
80 ********************************************************************************
81 */
82
83#include "Collection_Array.inl"
84
85#endif /*_Stroika_Foundation_Containers_Concrete_Collection_Array_h_ */
Implementation detail for Collection<T> implementors.
Definition Collection.h:376
A Collection<T> is a container to manage an un-ordered collection of items, without equality defined ...
Definition Collection.h:102
nonvirtual void AddAll(ITERATOR_OF_ADDABLE &&start, ITERATOR_OF_ADDABLE2 &&end)
typename inherited::value_type value_type
Definition Collection.h:116
Collection_Array<T> is an Array-based concrete implementation of the Collection<T> container pattern.
ArrayBasedContainer is a Stroika implementation detail, but its public methods are fair game and full...
static constexpr default_sentinel_t end() noexcept
Support for ranged for, and STL syntax in general.