new MultiMap()
Example -
var MultiMap = require("dsjslib").MultiMap
var mmap=new MultiMap()
- Source:
Methods
-
entries() → {Array}
-
Return a list of all key, value pairs. The key value pairs are returned as objects {'key':
,'value': } Note that for keys associated with multiple values there is one object per value returned in the entry for example for key1->val1,val2,val3 , the entries will be [{'key':key1,'value':val1},{'key':key1,'value':val2},{'key':key1,'value':val3}] - Source:
Returns:
Array of objects {'key':
,'value': } - Type
- Array
-
get(key) → {Array}
-
Search for key and return associated value array or empty array This method never returns null even if the key is not present Any changes made to the returned array modify the underlying array in the MultiMap as well
Parameters:
Name Type Description key
- Source:
Returns:
associated value Array
- Type
- Array
-
hasKey(key) → {Boolean}
-
Test if a key is present in Map or not. This doesn't modify the Map to create empty array if the key was not present.
Parameters:
Name Type Description key
- Source:
Returns:
true if key is present, false otherwise
- Type
- Boolean
-
put(key, value) → {MultiMap}
-
Insert a key value pair into the Map. If the key is already present, the value will be added to the existing list, otherwise, an array is created and the value is added to the array
Parameters:
Name Type Description key
* value
* - Source:
Returns:
this
- Type
- MultiMap
-
remove(key, value) → {Array}
-
If a value is provided, only that value is removed from the list If value is not provided, key and all values are deleted from the MultiMap
Parameters:
Name Type Description key
* value
* - Source:
Returns:
last value associated with the key
- Type
- Array