<V>(self: MutableHashSet<V>): MutableHashSet<V>Removes all values from the MutableHashSet, mutating the set in place. The set becomes empty after this operation.
When to use
Use to empty a mutable set while keeping the same set instance.
Example (Clearing all values)
import { MutableHashSet } from "effect"
const set = MutableHashSet.make("apple", "banana", "cherry")
console.log(MutableHashSet.size(set)) // 3
// Clear all values
MutableHashSet.clear(set)
console.log(MutableHashSet.size(set)) // 0
console.log(MutableHashSet.has(set, "apple")) // false
console.log(Array.from(set)) // []
// Can still add new values after clearing
MutableHashSet.add(set, "new")
console.log(MutableHashSet.size(set)) // 1export const const clear: <V>(
self: MutableHashSet<V>
) => MutableHashSet<V>
Removes all values from the MutableHashSet, mutating the set in place.
The set becomes empty after this operation.
When to use
Use to empty a mutable set while keeping the same set instance.
Example (Clearing all values)
import { MutableHashSet } from "effect"
const set = MutableHashSet.make("apple", "banana", "cherry")
console.log(MutableHashSet.size(set)) // 3
// Clear all values
MutableHashSet.clear(set)
console.log(MutableHashSet.size(set)) // 0
console.log(MutableHashSet.has(set, "apple")) // false
console.log(Array.from(set)) // []
// Can still add new values after clearing
MutableHashSet.add(set, "new")
console.log(MutableHashSet.size(set)) // 1
clear = <function (type parameter) V in <V>(self: MutableHashSet<V>): MutableHashSet<V>V>(self: MutableHashSet<V>(parameter) self: {
keyMap: MutableHashMap.MutableHashMap<V, boolean>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: interface MutableHashSet<out V>A mutable hash set for storing unique values with Effect structural equality
support.
When to use
Use to store and mutate a collection of unique values with Effect hashing and
equality semantics.
Details
Operations mutate the set in place. Values that implement Equal / Hash
can be de-duplicated structurally; other values use normal JavaScript
reference or primitive equality.
Example (Using a mutable hash set)
import { MutableHashSet } from "effect"
// Create a mutable hash set
const set: MutableHashSet.MutableHashSet<string> = MutableHashSet.make(
"apple",
"banana"
)
// Add elements
MutableHashSet.add(set, "cherry")
// Check if elements exist
console.log(MutableHashSet.has(set, "apple")) // true
console.log(MutableHashSet.has(set, "grape")) // false
// Iterate over elements
for (const value of set) {
console.log(value) // "apple", "banana", "cherry"
}
// Get size
console.log(MutableHashSet.size(set)) // 3
MutableHashSet<function (type parameter) V in <V>(self: MutableHashSet<V>): MutableHashSet<V>V>): interface MutableHashSet<out V>A mutable hash set for storing unique values with Effect structural equality
support.
When to use
Use to store and mutate a collection of unique values with Effect hashing and
equality semantics.
Details
Operations mutate the set in place. Values that implement Equal / Hash
can be de-duplicated structurally; other values use normal JavaScript
reference or primitive equality.
Example (Using a mutable hash set)
import { MutableHashSet } from "effect"
// Create a mutable hash set
const set: MutableHashSet.MutableHashSet<string> = MutableHashSet.make(
"apple",
"banana"
)
// Add elements
MutableHashSet.add(set, "cherry")
// Check if elements exist
console.log(MutableHashSet.has(set, "apple")) // true
console.log(MutableHashSet.has(set, "grape")) // false
// Iterate over elements
for (const value of set) {
console.log(value) // "apple", "banana", "cherry"
}
// Get size
console.log(MutableHashSet.size(set)) // 3
MutableHashSet<function (type parameter) V in <V>(self: MutableHashSet<V>): MutableHashSet<V>V> => (import MutableHashMapMutableHashMap.clear(self: MutableHashSet<V>(parameter) self: {
keyMap: MutableHashMap.MutableHashMap<V, boolean>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self.MutableHashSet<out V>.keyMap: MutableHashMap.MutableHashMap<V, boolean>(property) MutableHashSet<out V>.keyMap: {
backing: Map<K, V>;
buckets: Map<number, NonEmptyArray<K>>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
keyMap), self: MutableHashSet<V>(parameter) self: {
keyMap: MutableHashMap.MutableHashMap<V, boolean>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self)