<V>(self: MutableHashSet<V>): numberReturns the number of unique values in the MutableHashSet.
When to use
Use to read how many unique values are currently stored in the set.
Example (Checking set size)
import { MutableHashSet } from "effect"
const set = MutableHashSet.empty<string>()
console.log(MutableHashSet.size(set)) // 0
MutableHashSet.add(set, "apple")
MutableHashSet.add(set, "banana")
MutableHashSet.add(set, "apple") // Duplicate
console.log(MutableHashSet.size(set)) // 2
MutableHashSet.remove(set, "apple")
console.log(MutableHashSet.size(set)) // 1
MutableHashSet.clear(set)
console.log(MutableHashSet.size(set)) // 0elements
Source effect/MutableHashSet.ts:3881 lines
export const const size: <V>(
self: MutableHashSet<V>
) => number
Returns the number of unique values in the MutableHashSet.
When to use
Use to read how many unique values are currently stored in the set.
Example (Checking set size)
import { MutableHashSet } from "effect"
const set = MutableHashSet.empty<string>()
console.log(MutableHashSet.size(set)) // 0
MutableHashSet.add(set, "apple")
MutableHashSet.add(set, "banana")
MutableHashSet.add(set, "apple") // Duplicate
console.log(MutableHashSet.size(set)) // 2
MutableHashSet.remove(set, "apple")
console.log(MutableHashSet.size(set)) // 1
MutableHashSet.clear(set)
console.log(MutableHashSet.size(set)) // 0
size = <function (type parameter) V in <V>(self: MutableHashSet<V>): numberV>(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>): numberV>): number => import MutableHashMapMutableHashMap.size(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)