HashSet
Stores unique values in an immutable hash set.
A HashSet<A> contains at most one value for each equality class according to Effect's Equal and Hash rules. Membership checks, additions, removals, and set operations return new sets. This module also includes constructors, union, intersection, difference, subset checks, mapping, filtering, and reducing helpers.
Combinators
difference
Signature
declare const difference: {
<V1>(that: HashSet<V1>): <V0>(self: HashSet<V0>) => HashSet<V0>;
<V0, V1>(self: HashSet<V0>, that: HashSet<V1>): HashSet<V0>;
};intersection
Creates the intersection of two HashSets.
Signature
declare const intersection: {
<V1>(that: HashSet<V1>): <V0>(self: HashSet<V0>) => HashSet<V1 & V0>;
<V0, V1>(self: HashSet<V0>, that: HashSet<V1>): HashSet<V0 & V1>;
};Creates the union of two HashSets.
Signature
declare const union: {
<V1>(that: HashSet<V1>): <V0>(self: HashSet<V0>) => HashSet<V1 | V0>;
<V0, V1>(self: HashSet<V0>, that: HashSet<V1>): HashSet<V0 | V1>;
};Constructors
Creates an empty HashSet.
Signature
declare const empty: <V = never>() => HashSet<V>;fromIterable
Creates a HashSet from an iterable collection of values.
Signature
declare const fromIterable: <V>(values: Iterable<V>) => HashSet<V>;Creates a HashSet from a variable number of values.
Signature
declare const make: <Values extends ReadonlyArray<any>>(
...values: Values
) => HashSet<Values[number]>;Filtering
Filters the HashSet keeping only values that satisfy the predicate.
Signature
declare const filter: {
<V, U>(refinement: Refinement<NoInfer<V>, U>): (self: HashSet<V>) => HashSet<U>;
<V>(predicate: Predicate<NoInfer<V>>): (self: HashSet<V>) => HashSet<V>;
<V, U>(self: HashSet<V>, refinement: Refinement<V, U>): HashSet<U>;
<V>(self: HashSet<V>, predicate: Predicate<V>): HashSet<V>;
};Folding
Reduces the HashSet to a single value by iterating through the values and applying an accumulator function.
Signature
declare const reduce: {
<V, U>(zero: U, f: (accumulator: U, value: V) => U): (self: HashSet<V>) => U;
<V, U>(self: HashSet<V>, zero: U, f: (accumulator: U, value: V) => U): U;
};Getters
Guards
Mapping
Models
A HashSet is an immutable set data structure that provides efficient storage and retrieval of unique values. It uses a HashMap internally for optimal performance.
Signature
interface HashSet<out Value> extends Iterable<Value>, Equal, Pipeable, Inspectable {
readonly "~effect/collections/HashSet": "~effect/collections/HashSet";
}Mutations
Adds a value to the HashSet, returning a new HashSet.
Signature
declare const add: {
<V>(value: V): (self: HashSet<V>) => HashSet<V>;
<V>(self: HashSet<V>, value: V): HashSet<V>;
};Removes a value from the HashSet, returning a new HashSet.
Signature
declare const remove: {
<V>(value: V): (self: HashSet<V>) => HashSet<V>;
<V>(self: HashSet<V>, value: V): HashSet<V>;
};Other
Predicates
Checks whether all values in the HashSet satisfy the predicate.
Signature
declare const every: {
<V>(predicate: Predicate<V>): (self: HashSet<V>) => boolean;
<V>(self: HashSet<V>, predicate: Predicate<V>): boolean;
};Checks whether the HashSet contains the specified value.
Signature
declare const has: {
<V>(value: V): (self: HashSet<V>) => boolean;
<V>(self: HashSet<V>, value: V): boolean;
};Checks whether the HashSet is empty.
Signature
declare const isEmpty: <V>(self: HashSet<V>) => boolean;Checks whether a HashSet is a subset of another HashSet.
Signature
declare const isSubset: {
<V1>(that: HashSet<V1>): <V0>(self: HashSet<V0>) => boolean;
<V0, V1>(self: HashSet<V0>, that: HashSet<V1>): boolean;
};Checks whether at least one value in the HashSet satisfies the predicate.
Signature
declare const some: {
<V>(predicate: Predicate<V>): (self: HashSet<V>) => boolean;
<V>(self: HashSet<V>, predicate: Predicate<V>): boolean;
};
Creates the difference of two HashSets (elements in the first set that are not in the second).