blazemap
Implements a vector-based slab-like map with an interface similar to that of HashMap
,
and also provides tools for generating lightweight identifiers that can be type-safely used as keys for this map.
Usage
Currently, this crate provides 3 ways to create new types based on usize
that can be used as keys to BlazeMap
.
They are represented by the following macros and provide different optimizations.
1. define_key_wrapper!
Creates a new type that acts as an usize
-based replacement
for the old type that can be used as a key for blazemap
collections.
Example
use ;
define_key_wrapper!
let key_1 = new;
let key_2 = new;
let key_3 = new;
let mut map = new;
map.insert;
map.insert;
map.insert;
assert_eq!
2. define_key_wrapper_bounded!
Creates a new type that acts as an usize
-based replacement for the old
type that can be used as a key for blazemap
collections.
Being an analogue of define_key_wrapper!
for the case when the user could statically guarantee
that the number of unique keys doesn't exceed MAX_CAP
, it's optimized for
read operations so that they don't create any multi-thread contention.
Example
use ;
define_key_wrapper_bounded!
let key_1 = new;
let key_2 = new;
let key_3 = new;
let mut map = new;
map.insert;
map.insert;
map.insert;
assert_eq!
3. define_plain_id!
Creates a new type based on incrementally generated usize
instances
that can be used as a key for blazemap
collections. This is the most performant way to generate keys for BlazeMap
.
Example
use ;
define_plain_id!
let key_1 = new;
let key_2 = new;
let key_3 = new;
let mut map = new;
map.insert;
map.insert;
map.insert;
assert_eq!