commit | 99aea09761d20023154a03228fa1da730e32f1e4 | [log] [tgz] |
---|---|---|
author | Bob Badour <bbadour@google.com> | Thu Jul 28 19:14:48 2022 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Thu Jul 28 19:14:48 2022 +0000 |
tree | 8bb3381667a42f8ff4f1d123f88e1545e37ef30c | |
parent | 1aab6ec112a63ed1da8d0cf18dbdb0984806ea19 [diff] | |
parent | 49f05077ea62f7c6374976ce15709fdcc9240d98 [diff] |
[LSC] Add LOCAL_LICENSE_KINDS to external/rust/crates/indexmap am: 49f05077ea Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/indexmap/+/2168742 Change-Id: If85f6c690c1355815a673d2a09ca6738eb029946 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
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.