-
Notifications
You must be signed in to change notification settings - Fork 0
set
Subhajit Sahu edited this page Feb 10, 2020
·
7 revisions
Adds or updates an element with a specified key and a value to map.
BiMap.prototype.set(key, value);
// key: key of the element to add
// value: value of the element to add
// --> map (this)
const BiMap = require('extra-bimap');
var m = new BiMap();
// BiMap [Map] {}
m.set(1, 'a');
// BiMap [Map] { 1 => 'a' }
m.set(2, 'b');
// BiMap [Map] { 1 => 'a', 2 => 'b' }
m.set(2, 'a');
// Error: BiMap pair is not unique
m.set(2, 'c');
// BiMap [Map] { 1 => 'a', 2 => 'c' }