multi-map
multi-map copied to clipboard
Implement the whole HashMap interface
First of all, thank you very much for the quick responses and gentle guidance. I also stumbled over the missing len()
method, which I implemented for myself in my fork. A lot of these methods are very easy to pass through from the underlying HashMap
. Here is a list of all methods missing compared with HashMap
.
Methods
- [ ] capacity
- [ ] clear
- [ ] drain
- [ ] entry
- [ ] get_key_value and then also get_key_value_alt
- [ ] hasher
- [ ] is_empty
- [ ] iter_mut
- [ ] keys and then also get_keys_alt
- [x] len
- [ ] raw_entry maybe not
- [ ] raw_entry_mut maybe not
- [ ] remove_entry
- [ ] reserve
- [ ] retain
- [ ] shrink_to
- [ ] shrink_to_fit
- [ ] try_reserve
- [ ] values
- [ ] values_mut
- [ ] with_capacity_and_hasher
- [ ] with_hasher
Trait Implementations
- [ ] Clone
- [ ] Extend
- [ ] FromIterator
- [ ] Index
Blanket Implementations
- [ ] ToOwned
If you have no objections, I would try to implement some of the these, in the coming weeks and create PRs as soon as I accumulated a meaningful contribution. If someone else is working on it, we could check the boxes, to avoid duplicate work
I just bumped into not having clear()
which was a little disappointing (though I was able to work around it with mem::replace
).
Rather than tackling all of these, maybe it's best to attempt the low-hanging fruit first? I'd probably avoid naively implementing with_hasher
because you may want to use different hashers for each underlying HashMap, but things like values_mut
should be relatively straightforward. I'd like to PR some of these in, if this project is still maintained.
That sounds good to me @jeff-hiner :)
I implement almost whole list of requests, but there are some difficulties with naming of functions.
It is very difficult to remember that methods with "alt" it is methods with key 2, and without "alt" it's methods with key 1. And also these all methods names have different length, mismatched and not symmetrical.
Can we change the existing API? Renaming methods with suffix "key1", "key2" or "keys"? For example with changing the version of crate to 2.0.