<K, V>(): MutableHashMap<K, V>Creates an empty MutableHashMap.
When to use
Use to create a fresh mutable map before adding entries over time.
Details
Each call returns a new empty map instance.
Example (Creating an empty map)
import { MutableHashMap } from "effect"
const map = MutableHashMap.empty<string, number>()
// Add some entries
MutableHashMap.set(map, "key1", 42)
MutableHashMap.set(map, "key2", 100)
console.log(MutableHashMap.size(map)) // 2export const const empty: <K, V>() => MutableHashMap<
K,
V
>
Creates an empty MutableHashMap.
When to use
Use to create a fresh mutable map before adding entries over time.
Details
Each call returns a new empty map instance.
Example (Creating an empty map)
import { MutableHashMap } from "effect"
const map = MutableHashMap.empty<string, number>()
// Add some entries
MutableHashMap.set(map, "key1", 42)
MutableHashMap.set(map, "key2", 100)
console.log(MutableHashMap.size(map)) // 2
empty = <function (type parameter) K in <K, V>(): MutableHashMap<K, V>K, function (type parameter) V in <K, V>(): MutableHashMap<K, V>V>(): interface MutableHashMap<out K, out V>A mutable hash map that stores key-value pairs and supports both referential
and Effect structural equality.
When to use
Use as a mutable key-value map when in-place updates are acceptable and keys
may rely on Effect structural equality.
Details
Operations mutate the map in place. Keys that implement Equal / Hash can
be looked up structurally; other keys use normal JavaScript reference or
primitive equality.
Example (Using a mutable hash map)
import { MutableHashMap } from "effect"
// Create a mutable hash map with string keys and number values
const map: MutableHashMap.MutableHashMap<string, number> = MutableHashMap
.empty()
// Add some data
MutableHashMap.set(map, "count", 42)
MutableHashMap.set(map, "total", 100)
// Use as iterable
for (const [key, value] of map) {
console.log(`${key}: ${value}`)
}
// Output:
// count: 42
// total: 100
// Convert to array
const entries = Array.from(map)
console.log(entries) // [["count", 42], ["total", 100]]
MutableHashMap<function (type parameter) K in <K, V>(): MutableHashMap<K, V>K, function (type parameter) V in <K, V>(): MutableHashMap<K, V>V> => {
const const self: anyself = var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.create(o: object | null): any (+1 overload)Creates an object that has the specified prototype or that has null prototype.
create(const MutableHashMapProto: Omit<
MutableHashMap<unknown, unknown>,
"backing" | "buckets" | "bucketsSize"
>
MutableHashMapProto)
const self: anyself.backing = new var Map: MapConstructor
new () => Map<any, any> (+3 overloads)
Map()
const self: anyself.buckets = new var Map: MapConstructor
new () => Map<any, any> (+3 overloads)
Map()
return const self: anyself
}