static immutable long[6] list = [0, 1, 42, 32_767, -32_768, 0]; enum N = list.length; auto a = HashSet!long(N); auto b = HashSet!long(); a.rehash(N); assert(a.capacity == N); foreach (n; list) a.add(n); assert(a.length == N - 1); // one less because of the duplicate 0 assert(a != b); b = a.dup; assert(a !is b && a == b); // structural equality works
The safer HashSet
Unordered hash set.