UnsafeHashSet

Unordered hash set.

alias UnsafeHashSet(T) = UnsafeHashMap!(T, Unit)

Examples

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

See Also

The safer HashSet