structures/bimap

A bidirectional map (BiMap) A data structure similar to a Dictionary but stores the association in both directions

For example, keys have association to values:

animal → cat
color → red

And values have reverse association to those keys

cat → animal
red → color

Types

pub opaque type BiMap(k, v)

Values

pub fn delete(from from: BiMap(k, v), key key: k) -> BiMap(k, v)

Delete a key and associated value from the bimap

pub fn delete_val(
  from from: BiMap(k, v),
  value value: v,
) -> BiMap(k, v)

Delete a value and associated key from the bimap

pub fn get(from from: BiMap(k, v), key key: k) -> Result(v, Nil)

Get the associated value for a key

pub fn get_val(
  from from: BiMap(k, v),
  value value: v,
) -> Result(k, Nil)

Get the associated key for a value

pub fn insert(
  into into: BiMap(k, v),
  key key: k,
  value value: v,
) -> BiMap(k, v)

Insert a key an associated value

pub fn new() -> BiMap(a, b)
Search Document