pub type FnvIndexMap<K, V, const N: usize> = IndexMap<K, V, BuildHasherDefault<FnvHasher>, N>;
Expand description
A IndexMap
using the default FNV hasher
A list of all Methods and Traits available for FnvIndexMap
can be found in
the IndexMap
documentation.
§Examples
use heapless::FnvIndexMap;
// A hash map with a capacity of 16 key-value pairs allocated on the stack
let mut book_reviews = FnvIndexMap::<_, _, 16>::new();
// review some books.
book_reviews.insert("Adventures of Huckleberry Finn", "My favorite book.").unwrap();
book_reviews.insert("Grimms' Fairy Tales", "Masterpiece.").unwrap();
book_reviews.insert("Pride and Prejudice", "Very enjoyable.").unwrap();
book_reviews.insert("The Adventures of Sherlock Holmes", "Eye lyked it alot.").unwrap();
// check for a specific one.
if !book_reviews.contains_key("Les Misérables") {
println!("We've got {} reviews, but Les Misérables ain't one.",
book_reviews.len());
}
// oops, this review has a lot of spelling mistakes, let's delete it.
book_reviews.remove("The Adventures of Sherlock Holmes");
// look up the values associated with some keys.
let to_find = ["Pride and Prejudice", "Alice's Adventure in Wonderland"];
for book in &to_find {
match book_reviews.get(book) {
Some(review) => println!("{}: {}", book, review),
None => println!("{} is unreviewed.", book)
}
}
// iterate over everything.
for (book, review) in &book_reviews {
println!("{}: \"{}\"", book, review);
}
Aliased Type§
struct FnvIndexMap<K, V, const N: usize> { /* private fields */ }
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.