Stroika Library
3.0d18
Help-Home
Loading...
Searching...
No Matches
Sequence.cpp
1
/*
2
* Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3
*/
4
#include "Stroika/Foundation/StroikaPreComp.h"
5
6
#include "
Stroika/Foundation/Characters/String.h
"
7
#include "
Stroika/Foundation/Characters/ToString.h
"
8
#include "Stroika/Foundation/Containers/Mapping.h"
9
#include "
Stroika/Foundation/Debug/Trace.h
"
10
11
// Not generally included, but you can include these if you want to select a particular backend implementation
12
#include "
Stroika/Foundation/Containers/Concrete/Sequence_Array.h
"
13
#include "
Stroika/Foundation/Containers/Concrete/Sequence_DoublyLinkedList.h
"
14
#include "
Stroika/Foundation/Containers/Concrete/Sequence_LinkedList.h
"
15
16
#include "
Stroika/Foundation/Debug/Assertions.h
"
17
18
#include "Sequence.h"
19
20
using namespace
std
;
21
22
using namespace
Stroika::Foundation
;
23
using namespace
Stroika::Foundation::Containers
;
24
25
namespace
{
26
void
SimplestSequenceTest_ ()
27
{
28
/*
29
* A sequence is just a collection, where each item has a well-defined (index) order.
30
* Think of it as a SortedMapping<int,T> where the int is the index. Or maybe a bit
31
* like vector<T>, except that the 'vector' might be implemented with a different data structure, and have
32
* very different performance characteristics.
33
*
34
* For example, use Sequence_DoublyLinkedList, if you want to keep a sequential order, but don't use indexing, and care that
35
* you never need to 'pause for realloc'.
36
*/
37
Sequence<int>
s;
38
s.
Append
(3);
39
s += 4;
40
for
([[maybe_unused]]
int
i : s) {
41
Assert (i == 3 or i == 4);
42
}
43
Assert (s.
size
() == 2);
44
Assert (s[0] == 3);
45
Assert (s[1] == 4);
46
}
47
}
48
49
void
Samples::Containers::Sequence::RunDemo ()
50
{
51
SimplestSequenceTest_ ();
52
}
Assertions.h
Sequence_Array.h
Sequence_DoublyLinkedList.h
Sequence_LinkedList.h
String.h
ToString.h
Trace.h
Stroika::Foundation::Containers::Sequence
A generalization of a vector: a container whose elements are keyed by the natural numbers.
Definition
Library/Sources/Stroika/Foundation/Containers/Sequence.h:187
Stroika::Foundation::Containers::Sequence::Append
nonvirtual void Append(ArgByValueType< value_type > item)
Definition
Sequence.inl:330
Stroika::Foundation::Traversal::Iterable::size
nonvirtual size_t size() const
Returns the number of items contained.
Definition
Iterable.inl:302
Stroika::Foundation::Containers
Definition
String.h:55
Stroika::Foundation
Definition
BloomFilter.h:22
std
STL namespace.
Samples
Containers
Sources
Sequence.cpp
Generated by
1.9.8