-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement
MutableIntMap
(#3303)
`MutableIntMap` is an internally mutable variant of `IntMap`. The underlying tree is still a persistent data structure, so cloning is constant time and different copies of the same `MutableIntMap` can be modified independently. And the performance is similar, since it's based on the same internals. It is intended as a drop-in replacement for `BTreeMap` (hence the internal mutability as opposed to the purely functional interface of `IntMap`). For that reason, it also implements `remove()`, `split_off()` and `extend()`; as well as a couple of syntactic sugar methods (e.g. `keys()` and `values()`). And it provides support for any integer-like keys (that can be efficiently mapped to `u64` or `u128`). The main performance difference between `IntMap` and `MutableIntMap` comes from (i) having `insert()` return the previous value; and (ii) keeping track of / recalculating the size of the map, so that `len()` completes in constant time. --------- Co-authored-by: Stefan Schneider <[email protected]>
- Loading branch information
1 parent
6704c14
commit 760e1f7
Showing
9 changed files
with
1,456 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.