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.

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

Meta