Skip to content

Commit a31003c

Browse files
authored
Merge pull request #219 from cuviper/v2
Prepare for indexmap 2.0
2 parents 275379c + c715675 commit a31003c

25 files changed

+577
-592
lines changed

.github/workflows/ci.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
include:
19-
- rust: 1.49.0 # MSRV
19+
- rust: 1.56.0 # MSRV
2020
features:
2121
- rust: stable
2222
features: serde
@@ -30,8 +30,6 @@ jobs:
3030
features:
3131
- rust: nightly
3232
bench: test build benchmarks
33-
- rust: nightly
34-
features: test_low_transition_point
3533

3634
steps:
3735
- uses: actions/checkout@v2
@@ -59,7 +57,7 @@ jobs:
5957
strategy:
6058
matrix:
6159
include:
62-
- rust: 1.49.0
60+
- rust: 1.56.0
6361
target: thumbv6m-none-eabi
6462
- rust: stable
6563
target: thumbv6m-none-eabi
@@ -74,7 +72,7 @@ jobs:
7472
target: ${{ matrix.target }}
7573
- name: Tests
7674
run: |
77-
cargo build -vv --target=${{ matrix.target }}
75+
cargo build -vv --target=${{ matrix.target }} --no-default-features
7876
cargo build -v -p test-nostd --target=${{ matrix.target }}
7977
8078
clippy:

.rustfmt.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
edition = "2018"
1+
edition = "2021"

Cargo.toml

+9-31
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,19 @@
11
[package]
22
name = "indexmap"
3-
edition = "2018"
4-
version = "1.8.1"
5-
authors = [
6-
"bluss",
7-
"Josh Stone <[email protected]>"
8-
]
3+
edition = "2021"
4+
version = "2.0.0-pre"
5+
publish = false
96
documentation = "https://docs.rs/indexmap/"
107
repository = "https://github.com/bluss/indexmap"
11-
license = "Apache-2.0/MIT"
12-
description = """
13-
A hash table with consistent order and fast iteration.
14-
15-
The indexmap is a hash table where the iteration order of the key-value
16-
pairs is independent of the hash values of the keys. It has the usual
17-
hash table functionality, it preserves insertion order except after
18-
removals, and it allows lookup of its elements by either hash table key
19-
or numerical index. A corresponding hash set type is also provided.
20-
21-
This crate was initially published under the name ordermap, but it was renamed to
22-
indexmap.
23-
"""
24-
8+
license = "Apache-2.0 OR MIT"
9+
description = "A hash table with consistent order and fast iteration."
2510
keywords = ["hashmap", "no_std"]
2611
categories = ["data-structures", "no-std"]
27-
28-
build = "build.rs"
12+
rust-version = "1.56"
2913

3014
[lib]
3115
bench = false
3216

33-
[build-dependencies]
34-
autocfg = "1"
3517
[dependencies]
3618
serde = { version = "1.0", optional = true, default-features = false }
3719
rayon = { version = "1.4.1", optional = true }
@@ -41,7 +23,7 @@ rayon = { version = "1.4.1", optional = true }
4123
rustc-rayon = { version = "0.3", optional = true }
4224

4325
[dependencies.hashbrown]
44-
version = "0.11"
26+
version = "0.12"
4527
default-features = false
4628
features = ["raw"]
4729

@@ -55,14 +37,10 @@ fxhash = "0.2.1"
5537
serde_derive = "1.0"
5638

5739
[features]
58-
# Serialization with serde 1.0
59-
serde-1 = ["serde"]
60-
61-
# Force the use of `std`, bypassing target detection.
40+
default = ["std"]
6241
std = []
6342

6443
# for testing only, of course
65-
test_low_transition_point = []
6644
test_debug = []
6745

6846
[profile.bench]
@@ -73,7 +51,7 @@ no-dev-version = true
7351
tag-name = "{{version}}"
7452

7553
[package.metadata.docs.rs]
76-
features = ["serde-1", "rayon"]
54+
features = ["serde", "rayon"]
7755

7856
[workspace]
7957
members = ["test-nostd", "test-serde"]

README.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# indexmap
2+
3+
[![build status](https://github.com/bluss/indexmap/workflows/Continuous%20integration/badge.svg?branch=master)](https://github.com/bluss/indexmap/actions)
4+
[![crates.io](https://img.shields.io/crates/v/indexmap.svg)](https://crates.io/crates/indexmap)
5+
[![docs](https://docs.rs/indexmap/badge.svg)](https://docs.rs/indexmap)
6+
[![rustc](https://img.shields.io/badge/rust-1.56%2B-orange.svg)](https://img.shields.io/badge/rust-1.56%2B-orange.svg)
7+
8+
A pure-Rust hash table which preserves (in a limited sense) insertion order.
9+
10+
This crate implements compact map and set data-structures,
11+
where the iteration order of the keys is independent from their hash or
12+
value. It preserves insertion order (except after removals), and it
13+
allows lookup of entries by either hash table key or numerical index.
14+
15+
Note: this crate was originally released under the name `ordermap`,
16+
but it was renamed to `indexmap` to better reflect its features.
17+
18+
# Background
19+
20+
This was inspired by Python 3.6's new dict implementation (which remembers
21+
the insertion order and is fast to iterate, and is compact in memory).
22+
23+
Some of those features were translated to Rust, and some were not. The result
24+
was 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,
35+
which 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+
55+
See [RELEASES.md](https://github.com/bluss/indexmap/blob/master/README.md).

README.rst

-69
This file was deleted.

0 commit comments

Comments
 (0)