Skip to content

Commit 59f7a51

Browse files
committed
Document methods
1 parent 497b756 commit 59f7a51

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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>()
1921
map.set('a', 1)
2022
map.set('a', 2)
2123
map.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
```

0 commit comments

Comments
 (0)