Construct with rhsCapacity.
Construct with elements es.
Construct with elements in es.
Index modulo radix type.
ElementType type T.
Variant of opIndex with compile-time range checking.
Get last element.
Get first element.
Get length.
Pop last (back) element.
Pop first (front) element.
Pop n front elements.
Push/Add elements es at back. NOTE Doesn't invalidate any borrow.
Default key separator in printing.
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);
Statically allocated Mod-array of fixed pre-allocated length capacity of Mod-elements in chunks of elementLength. ElementType is Mod[elementLength].