Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Queue_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_Queue_Array_h_
5#define _Stroika_Foundation_Containers_Concrete_Queue_Array_h_
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
11
12/**
13 * \file
14 *
15 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
16 *
17 * TODO:
18 * @todo Add "MAX ENTRIES" feature - so throws/crashes when exceeded. Useful for a variety
19 * of queues, but I'm thinking mostly of Queue of incoming signals and need to avoid
20 * malloc call.
21 *
22 * @todo Redo using circular array strategy (we have this code in OLD stroika!!!)
23 */
24
26
27 /**
28 * \brief Queue_Array<T> is an Array-based concrete implementation of the Queue<T> container pattern.
29 *
30 * \note Runtime performance/complexity:
31 * o size () is constant complexity
32 *
33 * \note \em Thread-Safety <a href="Thread-Safety.md#C++-Standard-Thread-Safety">C++-Standard-Thread-Safety</a>
34 */
35 template <typename T>
36 class Queue_Array : public Private::ArrayBasedContainer<Queue_Array<T>, Queue<T>, false> {
37 private:
39
40 public:
41 using value_type = typename inherited::value_type;
42
43 public:
44 /**
45 * \see docs on Queue<T> constructor
46 */
47 Queue_Array ();
48 Queue_Array (Queue_Array&&) noexcept = default;
49 Queue_Array (const Queue_Array&) noexcept = default;
50 Queue_Array (const initializer_list<value_type>& src);
51 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE>
52 requires (not derived_from<remove_cvref_t<ITERABLE_OF_ADDABLE>, Queue_Array<T>>)
53 explicit Queue_Array (ITERABLE_OF_ADDABLE&& src)
54#if qCompilerAndStdLib_RequiresNotMatchInlineOutOfLineForTemplateClassBeingDefined_Buggy
55 : Queue_Array{}
56 {
58 this->reserve (src.size ());
59 }
60 AddAllToTail (forward<ITERABLE_OF_ADDABLE> (src));
61 AssertRepValidType_ ();
62 }
63#endif
64 ;
65 template <IInputIterator<T> ITERATOR_OF_ADDABLE>
66 Queue_Array (ITERATOR_OF_ADDABLE&& start, ITERATOR_OF_ADDABLE&& end);
67
68 public:
69 /**
70 */
71 nonvirtual Queue_Array& operator= (Queue_Array&&) noexcept = default;
72 nonvirtual Queue_Array& operator= (const Queue_Array&) = default;
73
74 private:
75 class Rep_;
76
77 private:
78 nonvirtual void AssertRepValidType_ () const;
79 };
80
81}
82
83/*
84 ********************************************************************************
85 ******************************* Implementation Details *************************
86 ********************************************************************************
87 */
88
89#include "Queue_Array.inl"
90
91#endif /*_Stroika_Foundation_Containers_Concrete_Queue_Array_h_ */
Queue_Array<T> is an Array-based concrete implementation of the Queue<T> container pattern.
Definition Queue_Array.h:36
ArrayBasedContainer is a Stroika implementation detail, but its public methods are fair game and full...
A Queue is a first-in-first-out (FIFO) data structure, where elements are arranged in well-ordered fa...
Definition Queue.h:95
nonvirtual void AddAllToTail(ITERABLE_OF_ADDABLE &&s)
typename inherited::value_type value_type
Definition Queue.h:109
static constexpr default_sentinel_t end() noexcept
Support for ranged for, and STL syntax in general.
Concept checks if the given type T has a const size() method which can be called to return a size_t.
Definition Concepts.h:361