Construct with rhsCapacity.
Construct with elements es.
Construct with elements in es.
ElementType type T.
Variant of opIndex with compile-time range checking.
Get remaining space available. Name taken from the same member of https://docs.rs/fixedvec/0.2.3/fixedvec/
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 { 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) 10 { 11 return mod!radix(value); 12 } 13 } 14 else 15 { 16 alias Ix = ubyte; 17 static ubyte mk(ubyte value) 18 { 19 return value; 20 } 21 } 22 23 const ixs = [mk(11), mk(22), mk(33), mk(44)].s; 24 enum capacity = 7; 25 26 auto x = StaticModArray!(capacity, 1, 8, true)(ixs); 27 auto y = StaticModArray!(capacity, 1, 8, true)(mk(11), mk(22), mk(33), mk(44)); 28 29 assert(x == y); 30 31 assert(x.length == 4); 32 assert(x.available == 3); 33 assert(!x.empty); 34 35 assert(!x.contains([mk(10)].s)); 36 assert(x.contains([mk(11)].s)); 37 assert(x.contains([mk(22)].s)); 38 assert(x.contains([mk(33)].s)); 39 assert(x.contains([mk(44)].s)); 40 assert(!x.contains([mk(45)].s)); 41 42 assert(!x.contains(mk(10))); 43 assert(x.contains(mk(11))); 44 assert(x.contains(mk(22))); 45 assert(x.contains(mk(33))); 46 assert(x.contains(mk(44))); 47 assert(!x.contains(mk(45))); 48 49 assert(x.equal([11, 22, 33, 44].s[])); 50 assert(x.front == 11); 51 assert(x.back == 44); 52 assert(!x.full); 53 x.popFront(); 54 assert(x.equal([22, 33, 44].s[])); 55 assert(x.front == 22); 56 assert(x.back == 44); 57 assert(!x.full); 58 x.popBack(); 59 assert(x.equal([22, 33].s[])); 60 assert(x.front == 22); 61 assert(x.back == 33); 62 assert(!x.full); 63 x.popFront(); 64 assert(x.equal([33].s[])); 65 assert(x.front == 33); 66 assert(x.back == 33); 67 assert(!x.full); 68 x.popFront(); 69 assert(x.empty); 70 assert(!x.full); 71 assert(x.length == 0); 72 73 x.pushBack(mk(11), mk(22), mk(33), mk(44), mk(55), mk(66), mk(77)); 74 assert(x.equal([11, 22, 33, 44, 55, 66, 77].s[])); 75 assert(!x.empty); 76 assert(x.full); 77 78 x.popFrontN(3); 79 assert(x.equal([44, 55, 66, 77].s[])); 80 81 x.popFrontN(2); 82 assert(x.equal([66, 77].s[])); 83 84 x.popFrontN(1); 85 assert(x.equal([77].s[])); 86 87 x.popFrontN(1); 88 assert(x.empty); 89 90 x.pushBack(mk(1)).pushBack(mk(2)).equal([1, 2].s[]); 91 assert(x.equal([1, 2].s[])); 92 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].