Hyperlinkv0.8.0-beta.28

MutableHashMap

MutableHashMap.sizeconsteffect/MutableHashMap.ts:805
<K, V>(self: MutableHashMap<K, V>): number

Returns the number of key-value pairs in the MutableHashMap.

When to use

Use to read how many entries are currently stored in the mutable hash map.

Example (Checking map size)

import { MutableHashMap } from "effect"

const map = MutableHashMap.empty<string, number>()
console.log(MutableHashMap.size(map)) // 0

MutableHashMap.set(map, "key1", 42)
MutableHashMap.set(map, "key2", 100)
console.log(MutableHashMap.size(map)) // 2

MutableHashMap.remove(map, "key1")
console.log(MutableHashMap.size(map)) // 1

MutableHashMap.clear(map)
console.log(MutableHashMap.size(map)) // 0
elementsisEmpty
export const size = <K, V>(self: MutableHashMap<K, V>): number => self.backing.size
Referenced by 7 symbols