commit | 741622061fd02b0f5b479da681f1a79338d7eaec | [log] [tgz] |
---|---|---|
author | Sam Saccone <[email protected]> | Tue Jul 18 22:15:16 2023 +0000 |
committer | Automerger Merge Worker <[email protected]> | Tue Jul 18 22:15:16 2023 +0000 |
tree | 068d39b45f9d17b2cdf8a37625ba546baee0fa49 | |
parent | f460f039f6df81544b2f9c607ccc4ef5cbe1270a [diff] | |
parent | 597bcaf6fa4a6cae2cad1d63df9c6e40a59c15f1 [diff] |
Move OWNER reference master=>main. am: ed82322491 am: 3b1b043e80 am: df5b29144a am: dbc9a14b73 am: 597bcaf6fa Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/indexmap/+/2661240 Change-Id: I4fdeda808d94e6136528bb3df2f5ad35d4c5b21e Signed-off-by: Automerger Merge Worker <[email protected]>
A pure-Rust hash table which preserves (in a limited sense) insertion order.
This crate implements compact map and set data-structures, where the iteration order of the keys is independent from their hash or value. It preserves insertion order (except after removals), and it allows lookup of entries by either hash table key or numerical index.
Note: this crate was originally released under the name ordermap
, but it was renamed to indexmap
to better reflect its features.
This was inspired by Python 3.6's new dict implementation (which remembers the insertion order and is fast to iterate, and is compact in memory).
Some of those features were translated to Rust, and some were not. The result was indexmap, a hash table that has following properties:
.remove()
.HashMap
does.IndexMap
derives a couple of performance facts directly from how it is constructed, which is roughly:
A raw hash table of key-value indices, and a vector of key-value pairs.
Iteration is very fast since it is on the dense key-values.
Removal is fast since it moves memory areas only in the table, and uses a single swap in the vector.
Lookup is fast-ish because the initial 7-bit hash lookup uses SIMD, and indices are densely stored. Lookup also is slow-ish since the actual key-value pairs are stored separately. (Visible when cpu caches size is limiting.)
In practice, IndexMap
has been tested out as the hashmap in rustc in PR45282 and the performance was roughly on par across the whole workload.
If you want the properties of IndexMap
, or its strongest performance points fits your workload, it might be the best hash table implementation.
See RELEASES.md.