agnostic/internals/mutable_map

Types

A MutableMap functions like Gleam’s Dict and exposes a subset of the same api. As the name implies, there are some important things to know:

  • On the JavaScript target, updates to the map are performed in-place and will mutate the map directly.

  • On the JavaScript target, keys in the map are compared by reference, not by hash or value.

Gleam has neither mutable data structures nor reference equality, so it’s incredibly important to use this module with care. It is primarily intended to be used durring diffing to avoid the expensive overhead of (re)constructing event and keyed node lookups.

pub type MutableMap(key, value)

Values

pub fn delete(
  map: MutableMap(key, value),
  key: key,
) -> MutableMap(key, value)
pub fn get_or_compute(
  map: MutableMap(key, value),
  key: key,
  compute: fn() -> value,
) -> value
pub fn has_key(map: MutableMap(key, value), key: key) -> Bool
pub fn insert(
  map: MutableMap(key, value),
  key: key,
  value: value,
) -> MutableMap(key, value)
pub fn is_empty(map: MutableMap(key, value)) -> Bool
pub fn new() -> MutableMap(key, value)
pub fn size(map: MutableMap(key, value)) -> Int
pub fn unsafe_get(map: MutableMap(key, value), key: key) -> value
Search Document