File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# MultiMap
22
3- Store multiple values under each map key.
3+ The [ multimap] [ 1 ] data structure is a map in which more than one value may be stored under each key.
4+
5+ [ 1 ] : https://en.wikipedia.org/wiki/Multimap
46
57## Installation
68
@@ -19,8 +21,27 @@ const map = new MultiMap<string, number>()
1921map .set (' a' , 1 )
2022map .set (' a' , 2 )
2123map .get (' a' ) // => Set([1, 2])
24+ map .has (' a' ) // => true
25+ map .size // => 1
2226```
2327
28+ ### Methods
29+
30+ - ` get(key) ` - Retrieve the Set of values stored under a key or the empty Set if the key does not exist.
31+ - ` set(key, value) ` - Add a value to the key's set without removing previous values.
32+ - ` has(key) ` - Returns true if a value is stored under the key.
33+ - ` delete(key) ` - Remove key and all of key's values.
34+ - ` delete(key, value) ` - Remove a value from the key's set.
35+ - ` drain(value) ` - Remove a value from all keys that reference it.
36+ - ` clear() ` - Remove all keys and values to empty the map.
37+ - ` keys() ` - An iterator of map keys.
38+ - ` values() ` - An iterator of Sets of values for all keys.
39+ - ` entries() ` - An iterator of [ key, Set<value >] pairs.
40+
41+ ### Properties
42+
43+ - ` size ` - The number of keys in the map.
44+
2445## Development
2546
2647```
You can’t perform that action at this time.
0 commit comments