An implementation of the T1AH (Fast Positive Hash) hash function.
To include this crate in your program, add the following to your Cargo.toml
:
toml
[dependencies]
t1ha = "0.1"
t1ha
in a HashMap
The T1haHashMap
type alias is the easiest way to use the standard library’s HashMap
with t1ha
.
```rust use t1ha::T1haHashMap;
let mut map = T1haHashMap::default(); map.insert(1, "one"); map.insert(2, "two");
map = T1haHashMap::withcapacityand_hasher(10, Default::default()); map.insert(1, "one"); map.insert(2, "two"); ```
Note: the standard library’s HashMap::new
and HashMap::with_capacity
are only implemented for the RandomState
hasher, so using Default
to get the hasher is the next best option.
t1ha
in a HashSet
Similarly, T1haHashSet
is a type alias for the standard library’s HashSet
with `t1ha.
```rust use t1ha::T1haHashSet;
let mut set = T1haHashSet::default(); set.insert(1); set.insert(2);
set = T1haHashSet::withcapacityand_hasher(10, Default::default()); set.insert(1); set.insert(2); ```