Convert to UnsignedType u.
Create from UnsignedType u.
assignment from range
1 auto set = StaticDenseSetFilter!(Role)(); 2 static assert(set.sizeof == 1); 3 4 assert(set.toString == "StaticDenseSetFilter!(Role, true)([])"); 5 6 // inserts 7 foreach (const rel; [EnumMembers!Rel]) 8 { 9 assert(!set.contains(Role(rel))); 10 assert(!set.contains(Role(rel, true))); 11 12 set.insert(Role(rel)); 13 assert(set.contains(Role(rel))); 14 15 assert(!set.contains(Role(rel, true))); 16 set.insert(Role(rel, true)); 17 18 assert(set.contains(Role(rel))); 19 assert(set.contains(Role(rel, true))); 20 } 21 22 assert(set.toString == "StaticDenseSetFilter!(Role, true)([const(Role)(unknown, false), const(Role)(unknown, true), const(Role)(subClassOf, false), const(Role)(subClassOf, true), const(Role)(instanceOf, false), const(Role)(instanceOf, true), const(Role)(memberOf, false), const(Role)(memberOf, true)])"); 23 24 // removes 25 foreach (const rel; [EnumMembers!Rel]) 26 { 27 assert(set.contains(Role(rel))); 28 assert(set.contains(Role(rel, true))); 29 30 set.remove(Role(rel)); 31 assert(!set.contains(Role(rel))); 32 33 assert(set.contains(Role(rel, true))); 34 set.remove(Role(rel, true)); 35 36 assert(!set.contains(Role(rel))); 37 assert(!set.contains(Role(rel, true))); 38 } 39 40 assert(set.toString == "StaticDenseSetFilter!(Role, true)([])"); 41 42 auto fullSet = StaticDenseSetFilter!(Role).asFull; 43 44 foreach (const rel; [EnumMembers!Rel]) 45 { 46 assert(fullSet.contains(Role(rel))); 47 assert(fullSet.contains(Role(rel, true))); 48 } 49 50 auto emptySet = StaticDenseSetFilter!(Role)(); 51 52 foreach (const rel; [EnumMembers!Rel]) 53 { 54 assert(!emptySet.contains(Role(rel))); 55 assert(!emptySet.contains(Role(rel, true))); 56 }
set operations
1 import nxt.array_help : s; 2 3 enum E : ubyte { a, b, c, d, dAlias = d } 4 5 auto a = StaticDenseSetFilter!(E)([E.a].s[]); 6 auto b = StaticDenseSetFilter!(E)([E.b].s[]); 7 auto c = StaticDenseSetFilter!(E)([E.b].s[]); 8 9 auto a_or_b = StaticDenseSetFilter!(E)([E.a, E.b].s[]); 10 auto a_and_b = StaticDenseSetFilter!(E)(); 11 12 assert((a | b | c) == a_or_b); 13 assert((a & b) == a_and_b); 14 assert((a & a & b) == a_and_b); 15 16 a |= b; 17 assert(a == a_or_b);