zena:set
import {…} from 'zena:set';
Classes
HashSet
final class HashSet<T extends Hashable> extends MapBackedSet<T>
A set of unique values with efficient membership tests.
Iteration order is unspecified and can change as the set grows. Use OrderedHashSet from 'zena:collections' when insertion order matters.
new(capacity: i32 = 16)
Interfaces
Set
interface Set<T extends Hashable> extends Iterable<T>
size: i32 { get; }
add(value: T): boolean
Adds a value to the set. Returns true if the value was newly added, false if it already existed.
has(value: T): boolean
Checks if the set contains the given value.
delete(value: T): boolean
Removes a value from the set. Returns true if the value was removed, false if it didn't exist.
clear(): void
Removes all values from the set.
operator [](value: T): boolean
Checks if the set contains the given value.
6 inherited members
Iterable
contains(value: T): boolean
Returns true if the collection contains the specified value.
all(predicate: (item: T) => boolean): boolean
Returns true if all elements match the given predicate. Returns true if the collection is empty.
some(predicate: (item: T) => boolean): boolean
Returns true if at least one element matches the given predicate. Returns false if the collection is empty.
fold<R>(initial: R, combine: (acc: R, item: T) => R): R
Reduces the collection to a single value by accumulating state.
find(predicate: (item: T) => boolean): inline (true, T) | inline (false, _)
Finds the first element that matches the predicate. Returns an inline tuple (true, item) if found, or (false, _) if not.
filter(predicate: (item: T) => boolean): Iterable<T>
Returns a new iterable containing only the elements that match the predicate.