Crates.io | ordermap |
lib.rs | ordermap |
version | |
source | src |
created_at | 2016-09-16 16:58:15.514087 |
updated_at | 2024-12-01 01:20:00.406308 |
description | A hash table with consistent order and fast iteration. |
homepage | |
repository | https://github.com/indexmap-rs/ordermap |
max_upload_size | |
id | 6517 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
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 in most mutating operations, and it allows lookup of entries by either hash table key or numerical index.
Note: this crate was originally what became the indexmap
crate, and
it was deprecated for a while in favor of that, but then ordermap
returned as a wrapper over indexmap
with stronger ordering properties.
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 results
were ordermap
and indexmap
, hash tables that have following properties:
.swap_remove()
or other methods that explicitly change order.
ordermap
, the regular .remove()
does preserve insertion order,
equivalent to what indexmap
calls .shift_remove()
.HashMap
does.Since its reintroduction in 0.5, ordermap
has also used its entry order for
PartialEq
and Eq
, whereas indexmap
considers the same entries in any order
to be equal for drop-in compatibility with HashMap
semantics. Using the order
is faster, and also allows ordermap
to implement PartialOrd
, Ord
, and Hash
.
OrderMap
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.
OrderMap
should maintain the same performance as IndexMap
for most operations, with the main difference being the removal strategy.OrderMap
has been tested out as the hashmap in rustc in PR45282 and
the performance was roughly on par across the whole workload.OrderMap
, or its strongest performance points
fits your workload, it might be the best hash table implementation.See RELEASES.md.