slabmap
This crate provides the type SlabMap
.
SlabMap
is HashMap-like collection that automatically determines the key.
Install
Add this to your Cargo.toml:
[]
= "0.2.0"
Examples
use SlabMap;
let mut s = new;
let key_a = s.insert;
let key_b = s.insert;
assert_eq!;
assert_eq!;
for in &s
assert_eq!;
assert_eq!;
The difference between SlabMap
and HashMap
SlabMap
can only use usize as a key.- The key of
SlabMap
is determined automatically. SlabMap
runs faster thanHashMap
.
The difference between SlabMap
and Slab
Carl Lerche's slab
crate provides a slab implementation with a similar API.
For both Slab
and SlabMap
, after adding many elements to the collection, removing many element will reduce iterate performance.
However, unlike Slab
, SlabMap
can improve iterate performance by calling SlabMap::optimize()
.
Performance
The following chart shows the difference in performance between
BTreeMap
,
HashMap
,
Slab
(version 0.4.2),
SlabMap
(version 0.1.0) and,
Vec
,
Insert
Remove random elements
Random access
Sequential access
Sequential access after removing elements from a 10,000-element collection
- x-axis : number of remaining elements
- y-axis : average time (lower is better)
License
This project is dual licensed under Apache-2.0/MIT. See the two LICENSE-* files for details.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.