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 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) => 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);
Statically allocated Mod-array of fixed pre-allocated length capacity of Mod-elements in chunks of elementLength. ElementType is Mod[elementLength].