indexed_map

Crates.ioindexed_map
lib.rsindexed_map
version0.1.1
sourcesrc
created_at2019-08-15 16:45:13.347203
updated_at2019-08-15 16:57:11.025819
descriptionHashMap wrapper where each value corresponds to a uniquely generated usize key.
homepage
repositoryhttps://github.com/cameronp98/indexed-map
max_upload_size
id157111
size6,003
Cameron Phillips (cameronp98)

documentation

README

indexed_map

A wrapper for HashMap that maps each value to a uniquely generated usize key.

Crates.io Crates.io Build Status

Example usage:

use indexed_map::IndexedMap;

fn  main() {
    // create an empty `IndexedMap`, just like `HashMap`
    let mut fruits = IndexedMap::new();
    
    // insert some values and store their keys for later use
    let apple = fruits.insert("Apple");
    let orange = fruits.insert("Orange");
    let pear = fruits.insert("Pear");
    
    // list the values we've inserted
    for fruit in fruits.inner().values() {
        println!("{}", fruit);
    }
    
    // remove the values using the unique keys returned from `IndexedMap::insert`
    fruits.inner_mut().remove(&apple);
    fruits.inner_mut().remove(&orange);
    fruits.inner_mut().remove(&pear);
    
    // the map is now empty
    println!("{:?}", fruits);
}
Commit count: 12

cargo fmt