A bi-directional map, with unique keys to unique values. Internally,
its a map and its inverse map which allows value to be looked up through
key, and key through value.
Eg. email id <-> person name
.
const BiMap = ;// : all Map() functions available var m = ;// BiMap [Map] {} m;// BiMap [Map] { 1 => 'a' } m;// BiMap [Map] { 1 => 'a', 2 => 'b' } m;// Error: BiMap pair is not unique minverse;// BiMap [Map] { 'a' => 1, 'b' => 2 } minverse;// Error: BiMap pair is not unique minverse;// BiMap [Map] { 'a' => 1, 'b' => 3 } minverseinverse// BiMap [Map] { 1 => 'a', 3 => 'b' } m;// BiMap [Map] { 3 => 'b' } minverse// false
reference
Name | Action |
---|---|
BiMap | Creates a bi-directional map, with unique keys to unique values. |
inverse | Gives reversed bi-directional map. |
clear | Removes all elements from map. |
delete | Removes the specified element from map. |
set | Adds or updates an element with a specified key and a value to map. |
size | Same as Map. |
entries | Same as Map. |
forEach | Same as Map. |
get | Same as Map. |
has | Same as Map. |
keys | Same as Map. |
values | Same as Map. |
@@iterator | Same as Map. |