Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Sequence_LinkedList.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_Sequence_LinkedList_h_
5#define _Stroika_Foundation_Containers_Concrete_Sequence_LinkedList_h_
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include "Stroika/Foundation/Containers/Sequence.h"
10
11/**
12 * \file
13 *
14 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
15 *
16 */
17
19
20 /**
21 * \brief Sequence_LinkedList<T> is a LinkedList-based concrete implementation of the Sequence<T> container pattern.
22 *
23 * \note Runtime performance/complexity:
24 *
25 * Suitable for short lists, low memory overhead, where you can new entries, and remove from the start
26 * (or if array indexing is rare). To keep the order, but not use it much.
27 *
28 * o size () is O(N), but empty () is constant
29 * o Append () is O(N)
30 * o Prepend () is constant complexity
31 * o Indexing (GetAt/SetAt,operator[]) are O(N)
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 Sequence_LinkedList : public Sequence<T> {
37 private:
38 using inherited = Sequence<T>;
39
40 public:
41 using value_type = typename inherited::value_type;
42
43 public:
44 /**
45 * \see docs on Sequence<> constructor
46 */
48 Sequence_LinkedList (Sequence_LinkedList&&) noexcept = default;
49 Sequence_LinkedList (const Sequence_LinkedList&) noexcept = default;
50 Sequence_LinkedList (const initializer_list<value_type>& src);
51 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE>
52 requires (not derived_from<remove_cvref_t<ITERABLE_OF_ADDABLE>, Sequence_LinkedList<T>>)
53 explicit Sequence_LinkedList (ITERABLE_OF_ADDABLE&& src)
54#if qCompilerAndStdLib_RequiresNotMatchInlineOutOfLineForTemplateClassBeingDefined_Buggy
56 {
57 this->AppendAll (forward<ITERABLE_OF_ADDABLE> (src));
58 AssertRepValidType_ ();
59 }
60#endif
61 ;
62 template <IInputIterator<T> ITERATOR_OF_ADDABLE>
63 Sequence_LinkedList (ITERATOR_OF_ADDABLE&& start, ITERATOR_OF_ADDABLE&& end);
64
65 public:
66 /**
67 */
68 nonvirtual Sequence_LinkedList& operator= (Sequence_LinkedList&&) noexcept = default;
69 nonvirtual Sequence_LinkedList& operator= (const Sequence_LinkedList&) = default;
70
71 private:
72 class Rep_;
73
74 private:
75 nonvirtual void AssertRepValidType_ () const;
76 };
77
78}
79
80/*
81 ********************************************************************************
82 ******************************* Implementation Details *************************
83 ********************************************************************************
84 */
85
86#include "Sequence_LinkedList.inl"
87
88#endif /*_Stroika_Foundation_Containers_Concrete_Sequence_LinkedList_h_ */
Sequence_LinkedList<T> is a LinkedList-based concrete implementation of the Sequence<T> container pat...
A generalization of a vector: a container whose elements are keyed by the natural numbers.
Definition Sequence.h:187
typename inherited::value_type value_type
Definition Sequence.h:198
nonvirtual void AppendAll(ITERABLE_OF_ADDABLE &&s)
static constexpr default_sentinel_t end() noexcept
Support for ranged for, and STL syntax in general.