StaticModArray

Statically allocated Mod-array of fixed pre-allocated length capacity of Mod-elements in chunks of elementLength. ElementType is Mod[elementLength].

Constructors

this
this(StaticModArray!(rhsCapacity, elementLength, span, useModuloFlag) rhs)

Construct with rhsCapacity.

this
this(Es es)

Construct with elements es.

this
this(Ix[] es)

Construct with elements in es.

Alias This

chunks

Members

Aliases

Ix
alias Ix = Mod!(radix, ubyte)

Index modulo radix type.

Ix
alias Ix = ubyte
Undocumented in source.
T
alias T = Ix

ElementType type T.

T
alias T = Ix[L]
Undocumented in source.

Functions

at
auto ref at()

Variant of opIndex with compile-time range checking.

available
auto available()

Get remaining space available. Name taken from the same member of https://docs.rs/fixedvec/0.2.3/fixedvec/

back
auto back()

Get last element.

chunks
auto chunks()
contains
bool contains(Ix[] key)
contains
bool contains(Mod!(radix, ModUInt) ix)
contains
bool contains(UInt ix)
Undocumented in source. Be warned that the author may not have intended to support it.
empty
bool empty()
front
auto front()

Get first element.

full
bool full()
length
auto length()

Get length.

popBack
auto ref popBack()

Pop last (back) element.

popFront
auto ref popFront()

Pop first (front) element.

popFrontN
auto ref popFrontN(size_t n)

Pop n front elements.

pushBack
auto ref pushBack(Es es)

Push/Add elements es at back. NOTE Doesn't invalidate any borrow.

Manifest constants

L
enum L;
Undocumented in source.
keySeparator
enum keySeparator;

Default key separator in printing.

typeBits
enum typeBits;
Undocumented in source.

Properties

toString
char toString [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

1 import std.algorithm : equal;
2 
3 version(useModulo)
4 {
5     enum span = 8;
6     enum radix = 2^^span;
7     import nxt.modulo : Mod, mod;
8     alias Ix = Mod!(radix, ubyte);
9     static Mod!radix mk(ubyte value) => mod!radix(value);
10 }
11 else
12 {
13     alias Ix = ubyte;
14     static ubyte mk(ubyte value) => value;
15 }
16 
17 const ixs = [mk(11), mk(22), mk(33), mk(44)].s;
18 enum capacity = 7;
19 
20 auto x = StaticModArray!(capacity, 1, 8, true)(ixs);
21 auto y = StaticModArray!(capacity, 1, 8, true)(mk(11), mk(22), mk(33), mk(44));
22 
23 assert(x == y);
24 
25 assert(x.length == 4);
26 assert(x.available == 3);
27 assert(!x.empty);
28 
29 assert(!x.contains([mk(10)].s));
30 assert(x.contains([mk(11)].s));
31 assert(x.contains([mk(22)].s));
32 assert(x.contains([mk(33)].s));
33 assert(x.contains([mk(44)].s));
34 assert(!x.contains([mk(45)].s));
35 
36 assert(!x.contains(mk(10)));
37 assert(x.contains(mk(11)));
38 assert(x.contains(mk(22)));
39 assert(x.contains(mk(33)));
40 assert(x.contains(mk(44)));
41 assert(!x.contains(mk(45)));
42 
43 assert(x.equal([11, 22, 33, 44].s[]));
44 assert(x.front == 11);
45 assert(x.back == 44);
46 assert(!x.full);
47 x.popFront();
48 assert(x.equal([22, 33, 44].s[]));
49 assert(x.front == 22);
50 assert(x.back == 44);
51 assert(!x.full);
52 x.popBack();
53 assert(x.equal([22, 33].s[]));
54 assert(x.front == 22);
55 assert(x.back == 33);
56 assert(!x.full);
57 x.popFront();
58 assert(x.equal([33].s[]));
59 assert(x.front == 33);
60 assert(x.back == 33);
61 assert(!x.full);
62 x.popFront();
63 assert(x.empty);
64 assert(!x.full);
65 assert(x.length == 0);
66 
67 x.pushBack(mk(11), mk(22), mk(33), mk(44), mk(55), mk(66), mk(77));
68 assert(x.equal([11, 22, 33, 44, 55, 66, 77].s[]));
69 assert(!x.empty);
70 assert(x.full);
71 
72 x.popFrontN(3);
73 assert(x.equal([44, 55, 66, 77].s[]));
74 
75 x.popFrontN(2);
76 assert(x.equal([66, 77].s[]));
77 
78 x.popFrontN(1);
79 assert(x.equal([77].s[]));
80 
81 x.popFrontN(1);
82 assert(x.empty);
83 
84 x.pushBack(mk(1)).pushBack(mk(2)).equal([1, 2].s[]);
85 assert(x.equal([1, 2].s[]));
86 assert(x.length == 2);

Meta