gleamy/bimap
This module provides a simple implementation of a bidirectional map.
Each key can have a single value, and each value can have a single key.
The bimap is based on Gleam dict.Dict
s, so ordering is not guaranteed.
Types
Values
pub fn delete_by_key(bimap: Bimap(a, b), key: a) -> Bimap(a, b)
Delete a key-value pair from the bimap by key.
pub fn delete_by_value(
bimap: Bimap(a, b),
value: b,
) -> Bimap(a, b)
Delete a key-value pair from the bimap by value.
pub fn from_list(members: List(#(a, b))) -> Bimap(a, b)
Create a bimap from list entries.
pub fn get_by_key(bimap: Bimap(a, b), key: a) -> Result(b, Nil)
Get a value by its key, if present.
pub fn get_by_value(
bimap: Bimap(a, b),
value: b,
) -> Result(a, Nil)
Get a key by its value, if present.
pub fn has_value(bimap: Bimap(a, b), value: b) -> Bool
Check if a value exists in the bimap.