Hyperlinkv0.8.0-beta.28

HashMap

HashMap.beginMutationconsteffect/HashMap.ts:714
<K, V>(self: HashMap<K, V>): HashMap<K, V>

Creates a transient mutable HashMap for efficient batched updates.

Details

Apply updates to the returned map, then call endMutation to finish the mutation window and use the result as an immutable HashMap.

Example (Beginning batch mutation)

import { HashMap } from "effect"

const map = HashMap.make(["a", 1])

// Begin mutation for efficient batch operations
const mutable = HashMap.beginMutation(map)

// Multiple operations are now more efficient
HashMap.set(mutable, "b", 2)
HashMap.set(mutable, "c", 3)
HashMap.remove(mutable, "a")

// End mutation to get final immutable result
const result = HashMap.endMutation(mutable)
console.log(HashMap.size(result)) // 2
mutations
Source effect/HashMap.ts:7141 lines
export const beginMutation: <K, V>(self: HashMap<K, V>) => HashMap<K, V> = internal.beginMutation