/** * @since 1.0.0 */ import type { Equal } from "@effect/data/Equal" import type { Inspectable } from "@effect/data/Inspectable" import * as HS from "@effect/data/internal/HashSet" import type { Pipeable } from "@effect/data/Pipeable" import type { Predicate, Refinement } from "@effect/data/Predicate" const TypeId: unique symbol = HS.HashSetTypeId as TypeId /** * @since 1.0.0 * @category symbol */ export type TypeId = typeof TypeId /** * @since 1.0.0 * @category models */ export interface HashSet extends Iterable, Equal, Pipeable, Inspectable { readonly [TypeId]: TypeId } /** * @since 1.0.0 * @category refinements */ export const isHashSet: { (u: Iterable): u is HashSet (u: unknown): u is HashSet } = HS.isHashSet /** * Creates an empty `HashSet`. * * @since 1.0.0 * @category constructors */ export const empty: () => HashSet = HS.empty /** * Construct a new `HashSet` from a `Collection` of values * * @since 1.0.0 * @category constructors */ export const fromIterable: (elements: Iterable) => HashSet = HS.fromIterable /** * Construct a new `HashSet` from a variable number of values. * * @since 1.0.0 * @category constructors */ export const make: >(...elements: As) => HashSet = HS.make /** * Checks if the specified value exists in the `HashSet`. * * @since 1.0.0 * @category elements */ export const has: { (value: A): (self: HashSet) => boolean (self: HashSet, value: A): boolean } = HS.has /** * Check if a predicate holds true for some `HashSet` element. * * @since 1.0.0 * @category elements */ export const some: { (f: Predicate): (self: HashSet) => boolean (self: HashSet, f: Predicate): boolean } = HS.some /** * Check if a predicate holds true for every `HashSet` element. * * @since 1.0.0 * @category elements */ export const every: { (refinement: Refinement): (self: HashSet) => self is HashSet (predicate: Predicate): (self: HashSet) => boolean (self: HashSet, refinement: Refinement): self is HashSet (self: HashSet, predicate: Predicate): boolean } = HS.every /** * Returns `true` if and only if every element in the this `HashSet` is an * element of the second set, * * **NOTE**: the hash and equal of both sets must be the same. * * @since 1.0.0 * @category elements */ export const isSubset: { (that: HashSet): (self: HashSet) => boolean (self: HashSet, that: HashSet): boolean } = HS.isSubset /** * Returns an `IterableIterator` of the values in the `HashSet`. * * @since 1.0.0 * @category getters */ export const values: (self: HashSet) => IterableIterator = HS.values /** * Calculates the number of values in the `HashSet`. * * @since 1.0.0 * @category getters */ export const size: (self: HashSet) => number = HS.size /** * Marks the `HashSet` as mutable. * * @since 1.0.0 */ export const beginMutation: (self: HashSet) => HashSet = HS.beginMutation /** * Marks the `HashSet` as immutable. * * @since 1.0.0 */ export const endMutation: (self: HashSet) => HashSet = HS.endMutation /** * Mutates the `HashSet` within the context of the provided function. * * @since 1.0.0 */ export const mutate: { (f: (set: HashSet) => void): (self: HashSet) => HashSet (self: HashSet, f: (set: HashSet) => void): HashSet } = HS.mutate /** * Adds a value to the `HashSet`. * * @since 1.0.0 */ export const add: { (value: A): (self: HashSet) => HashSet (self: HashSet, value: A): HashSet } = HS.add /** * Removes a value from the `HashSet`. * * @since 1.0.0 */ export const remove: { (value: A): (self: HashSet) => HashSet (self: HashSet, value: A): HashSet } = HS.remove /** * Computes the set difference between this `HashSet` and the specified * `Iterable`. * * **NOTE**: the hash and equal of the values in both the set and the iterable * must be the same. * * @since 1.0.0 */ export const difference: { (that: Iterable): (self: HashSet) => HashSet (self: HashSet, that: Iterable): HashSet } = HS.difference /** * Returns a `HashSet` of values which are present in both this set and that * `Iterable`. * * **NOTE**: the hash and equal of the values in both the set and the iterable * must be the same. * * @since 1.0.0 */ export const intersection: { (that: Iterable): (self: HashSet) => HashSet (self: HashSet, that: Iterable): HashSet } = HS.intersection /** * Computes the set union `(`self` + `that`)` between this `HashSet` and the * specified `Iterable`. * * **NOTE**: the hash and equal of the values in both the set and the iterable * must be the same. * * @since 1.0.0 */ export const union: { (that: Iterable): (self: HashSet) => HashSet (self: HashSet, that: Iterable): HashSet } = HS.union /** * Checks if a value is present in the `HashSet`. If it is present, the value * will be removed from the `HashSet`, otherwise the value will be added to the * `HashSet`. * * @since 1.0.0 */ export const toggle: { (value: A): (self: HashSet) => HashSet (self: HashSet, value: A): HashSet } = HS.toggle /** * Maps over the values of the `HashSet` using the specified function. * * @since 1.0.0 * @category mapping */ export const map: { (f: (a: A) => B): (self: HashSet) => HashSet (self: HashSet, f: (a: A) => B): HashSet } = HS.map /** * Chains over the values of the `HashSet` using the specified function. * * @since 1.0.0 * @category sequencing */ export const flatMap: { (f: (a: A) => Iterable): (self: HashSet) => HashSet (self: HashSet, f: (a: A) => Iterable): HashSet } = HS.flatMap /** * Applies the specified function to the values of the `HashSet`. * * @since 1.0.0 * @category traversing */ export const forEach: { (f: (value: A) => void): (self: HashSet) => void (self: HashSet, f: (value: A) => void): void } = HS.forEach /** * Reduces the specified state over the values of the `HashSet`. * * @since 1.0.0 * @category folding */ export const reduce: { (zero: Z, f: (accumulator: Z, value: A) => Z): (self: HashSet) => Z (self: HashSet, zero: Z, f: (accumulator: Z, value: A) => Z): Z } = HS.reduce /** * Filters values out of a `HashSet` using the specified predicate. * * @since 1.0.0 * @category filtering */ export const filter: { (f: Refinement): (self: HashSet) => HashSet (f: Predicate): (self: HashSet) => HashSet (self: HashSet, f: Refinement): HashSet (self: HashSet, f: Predicate): HashSet } = HS.filter /** * Partition the values of a `HashSet` using the specified predicate. * * If a value matches the predicate, it will be placed into the `HashSet` on the * right side of the resulting `Tuple`, otherwise the value will be placed into * the left side. * * @since 1.0.0 * @category partitioning */ export const partition: { ( refinement: Refinement ): (self: HashSet) => [HashSet>, HashSet] (predicate: (a: A) => boolean): (self: HashSet) => [HashSet, HashSet] ( self: HashSet, refinement: Refinement ): [HashSet>, HashSet] (self: HashSet, predicate: (a: A) => boolean): [HashSet, HashSet] } = HS.partition