On this page

zena:set

zena
import {…} from 'zena:set';

Classes

HashSet

zena
final class HashSet<T extends Hashable> extends MapBackedSet<T>
Extends MapBackedSet<T>
Re-exported from zena:collections/hash-set.zena

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.

Constructors
zena
new(capacity: i32 = 16)
#

Interfaces

Set

zena
interface Set<T extends Hashable> extends Iterable<T>
Extends Iterable<T>
Re-exported from zena:collections/set.zena
Properties
zena
size: i32 { get; }
#
Methods
zena
add(value: T): boolean
#

Adds a value to the set. Returns true if the value was newly added, false if it already existed.

zena
has(value: T): boolean
#

Checks if the set contains the given value.

zena
delete(value: T): boolean
#

Removes a value from the set. Returns true if the value was removed, false if it didn't exist.

zena
clear(): void
#

Removes all values from the set.

Operators
zena
operator [](value: T): boolean
#

Checks if the set contains the given value.

6 inherited members
From Iterable
zena
contains(value: T): boolean
#

Returns true if the collection contains the specified value.

zena
all(predicate: (item: T) => boolean): boolean
#

Returns true if all elements match the given predicate. Returns true if the collection is empty.

zena
some(predicate: (item: T) => boolean): boolean
#

Returns true if at least one element matches the given predicate. Returns false if the collection is empty.

zena
fold<R>(initial: R, combine: (acc: R, item: T) => R): R
#

Reduces the collection to a single value by accumulating state.

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

zena
filter(predicate: (item: T) => boolean): Iterable<T>
#

Returns a new iterable containing only the elements that match the predicate.