Package: effect
Module: MutableHashSet
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
Signature
declare const clear: <V>(self: MutableHashSet<V>) => MutableHashSet<V>
Since v2.0.0