Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
.github/workflows/ | 03-May-2024 | - | 115 | 106 | ||
benches/ | 03-May-2024 | - | 950 | 827 | ||
src/ | 03-May-2024 | - | 7,122 | 4,714 | ||
tests/ | 03-May-2024 | - | 677 | 552 | ||
.cargo_vcs_info.json | D | 03-May-2024 | 94 | 6 | 6 | |
.gitignore | D | 03-May-2024 | 18 | 3 | 2 | |
.rustfmt.toml | D | 03-May-2024 | 17 | 2 | 1 | |
Android.bp | D | 03-May-2024 | 2 KiB | 64 | 60 | |
Cargo.toml | D | 03-May-2024 | 2 KiB | 108 | 87 | |
Cargo.toml.orig | D | 03-May-2024 | 1.6 KiB | 66 | 52 | |
LICENSE | D | 03-May-2024 | 1 KiB | 26 | 22 | |
LICENSE-APACHE | D | 03-May-2024 | 10.6 KiB | 202 | 169 | |
LICENSE-MIT | D | 03-May-2024 | 1 KiB | 26 | 22 | |
METADATA | D | 03-May-2024 | 642 | 24 | 22 | |
MODULE_LICENSE_MIT | D | 03-May-2024 | 0 | |||
OWNERS | D | 03-May-2024 | 47 | 2 | 1 | |
README.md | D | 03-May-2024 | 2.5 KiB | 56 | 39 | |
RELEASES.md | D | 03-May-2024 | 12.5 KiB | 385 | 248 | |
build.rs | D | 03-May-2024 | 291 | 9 | 7 | |
cargo2android.json | D | 03-May-2024 | 61 | 6 | 5 |
README.md
1# indexmap 2 3[](https://github.com/bluss/indexmap/actions) 4[](https://crates.io/crates/indexmap) 5[](https://docs.rs/indexmap) 6[](https://img.shields.io/badge/rust-1.56%2B-orange.svg) 7 8A pure-Rust hash table which preserves (in a limited sense) insertion order. 9 10This crate implements compact map and set data-structures, 11where the iteration order of the keys is independent from their hash or 12value. It preserves insertion order (except after removals), and it 13allows lookup of entries by either hash table key or numerical index. 14 15Note: this crate was originally released under the name `ordermap`, 16but it was renamed to `indexmap` to better reflect its features. 17 18# Background 19 20This was inspired by Python 3.6's new dict implementation (which remembers 21the insertion order and is fast to iterate, and is compact in memory). 22 23Some of those features were translated to Rust, and some were not. The result 24was indexmap, a hash table that has following properties: 25 26- Order is **independent of hash function** and hash values of keys. 27- Fast to iterate. 28- Indexed in compact space. 29- Preserves insertion order **as long** as you don't call `.remove()`. 30- Uses hashbrown for the inner table, just like Rust's libstd `HashMap` does. 31 32## Performance 33 34`IndexMap` derives a couple of performance facts directly from how it is constructed, 35which is roughly: 36 37> A raw hash table of key-value indices, and a vector of key-value pairs. 38 39- Iteration is very fast since it is on the dense key-values. 40- Removal is fast since it moves memory areas only in the table, 41 and uses a single swap in the vector. 42- Lookup is fast-ish because the initial 7-bit hash lookup uses SIMD, and indices are 43 densely stored. Lookup also is slow-ish since the actual key-value pairs are stored 44 separately. (Visible when cpu caches size is limiting.) 45 46- In practice, `IndexMap` has been tested out as the hashmap in rustc in [PR45282] and 47 the performance was roughly on par across the whole workload. 48- If you want the properties of `IndexMap`, or its strongest performance points 49 fits your workload, it might be the best hash table implementation. 50 51[PR45282]: https://github.com/rust-lang/rust/pull/45282 52 53# Recent Changes 54 55See [RELEASES.md](https://github.com/bluss/indexmap/blob/master/RELEASES.md). 56