effect-io-ai

Package: effect
Module: MutableHashMap

MutableHashMap.size

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

See

Signature

declare const size: <K, V>(self: MutableHashMap<K, V>) => number

Source

Since v2.0.0