Type Definition heapless::FnvIndexMap [−][src]
type FnvIndexMap<K, V, N> = IndexMap<K, V, N, BuildHasherDefault<FnvHasher>>;
A heaples::IndexMap
using the default FNV hasher
A list of all Methods and Traits available for FnvIndexMap
can be found in
the heapless::IndexMap
documentation.
Examples
use heapless::FnvIndexMap; use heapless::consts::*; // A hash map with a capacity of 16 key-value pairs allocated on the stack let mut book_reviews = FnvIndexMap::<_, _, U16>::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); }