Set
sealed class Set<T> where T is Hashableimport Set from Wax;A collection of distinct values, using the element hash and equality operations.
Inherits from object. Follow these links for inherited members.
Members
constructorconstructor
public constructor ()Creates an empty set with no allocated entry capacity. The first insertion allocates storage.
WithCapacityconstructor
public constructor WithCapacity (int32 capacity)Creates an empty set and reserves room for the requested number of entries. The reported slot capacity can exceed the request. Reserving capacity does not insert entries.
sizegetter
public get size() : int32The number of live distinct elements. Adding an existing element leaves this count unchanged.
capacitygetter
public get capacity() : int32The number of allocated hash-table slots, not the number of entries that can be inserted before growth. Some slots are kept free for probing.
EnsureCapacitymethod
public fn EnsureCapacity(int32 capacity) : voidReserves room for at least the requested total entry count without removing entries or
shrinking storage. Does not change size. A reservation on a newly empty set
allocates a minimum table even for a zero request.
EnsureAdditionalCapacitymethod
public fn EnsureAdditionalCapacity(int32 additional) : voidReserves room for size + additional entries without changing size. Expresses an
additional entry count rather than a total capacity.
Addmethod
public fn Add(T item) : boolAdds an element unless an equal element already exists, returning whether a new element was inserted. Equal elements must have equal hashes; do not mutate stored elements in ways that change their hash or equality.
Hasmethod
public fn Has(T item) : boolTests membership using the element hash and Equals. An empty set returns false.
Removemethod
public fn Remove(T item) : boolRemoves an equal element and returns true, or false if absent. Capacity is retained; removed
references can remain until a table rebuild or Clear.
Clearmethod
public fn Clear() : voidRemoves every element and releases stored element references while keeping slot capacity.
ToArraymethod
public fn ToArray() : T[]Returns a new array snapshot in unspecified table order, not insertion order. Referenced objects are not cloned.
Unionmethod
public fn Union(Set<T> other) : voidMutates this set to include all elements of other. Uses a snapshot, so union with itself
is safe. Does not mutate a distinct other set.
Intersectmethod
public fn Intersect(Set<T> other) : voidMutates this set to retain only elements also present in other. Intersecting with itself
preserves its contents.
Exceptmethod
public fn Except(Set<T> other) : voidRemoves from this set every element present in other. Passing this set itself empties it.
IsSubsetOfmethod
public fn IsSubsetOf(Set<T> other) : boolReturns true when every element of this set exists in other. Equality counts as a subset;
the empty set is a subset of every set.
IsSupersetOfmethod
public fn IsSupersetOf(Set<T> other) : boolReturns true when every element of other exists here. Equality counts as a superset.
Overlapsmethod
public fn Overlaps(Set<T> other) : boolReturns true if the sets share at least one equal element. Returns false if either is empty.