← Standard library

Set

sealed class Set<T> where T is Hashable
import Set from Wax;

A collection of distinct values, using the element hash and equality operations.

Set.wax:17

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.

Set.wax:31

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.

Set.wax:45

sizegetter

public get size() : int32

The number of live distinct elements. Adding an existing element leaves this count unchanged.

Set.wax:58

capacitygetter

public get capacity() : int32

The number of allocated hash-table slots, not the number of entries that can be inserted before growth. Some slots are kept free for probing.

Set.wax:66

EnsureCapacitymethod

public fn EnsureCapacity(int32 capacity) : void

Reserves 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.

Set.wax:141

EnsureAdditionalCapacitymethod

public fn EnsureAdditionalCapacity(int32 additional) : void

Reserves room for size + additional entries without changing size. Expresses an additional entry count rather than a total capacity.

Set.wax:152

Addmethod

public fn Add(T item) : bool

Adds 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.

Set.wax:161

Hasmethod

public fn Has(T item) : bool

Tests membership using the element hash and Equals. An empty set returns false.

Set.wax:196

Removemethod

public fn Remove(T item) : bool

Removes an equal element and returns true, or false if absent. Capacity is retained; removed references can remain until a table rebuild or Clear.

Set.wax:222

Clearmethod

public fn Clear() : void

Removes every element and releases stored element references while keeping slot capacity.

Set.wax:251

ToArraymethod

public fn ToArray() : T[]

Returns a new array snapshot in unspecified table order, not insertion order. Referenced objects are not cloned.

Set.wax:266

Unionmethod

public fn Union(Set<T> other) : void

Mutates this set to include all elements of other. Uses a snapshot, so union with itself is safe. Does not mutate a distinct other set.

Set.wax:291

Intersectmethod

public fn Intersect(Set<T> other) : void

Mutates this set to retain only elements also present in other. Intersecting with itself preserves its contents.

Set.wax:304

Exceptmethod

public fn Except(Set<T> other) : void

Removes from this set every element present in other. Passing this set itself empties it.

Set.wax:318

IsSubsetOfmethod

public fn IsSubsetOf(Set<T> other) : bool

Returns true when every element of this set exists in other. Equality counts as a subset; the empty set is a subset of every set.

Set.wax:333

IsSupersetOfmethod

public fn IsSupersetOf(Set<T> other) : bool

Returns true when every element of other exists here. Equality counts as a superset.

Set.wax:347

Overlapsmethod

public fn Overlaps(Set<T> other) : bool

Returns true if the sets share at least one equal element. Returns false if either is empty.

Set.wax:361