Stroika Library 3.0d18
 
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
8#include "Stroika/Foundation/Containers/Mapping.h"
10
11// Not generally included, but you can include these if you want to select a particular backend implementation
15
17
18#include "Sequence.h"
19
20using namespace std;
21
22using namespace Stroika::Foundation;
24
25namespace {
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 */
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
49void Samples::Containers::Sequence::RunDemo ()
50{
51 SimplestSequenceTest_ ();
52}
A generalization of a vector: a container whose elements are keyed by the natural numbers.
nonvirtual void Append(ArgByValueType< value_type > item)
Definition Sequence.inl:330
nonvirtual size_t size() const
Returns the number of items contained.
Definition Iterable.inl:302
STL namespace.