Skip to content

vbrandl/countmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CountMap

Travis Build Status License License crates.io

Implementation of a count map in Rust. A map that holds a counter as a value, that gets incremented each time the key is added to the map. This implementation simply decorates the HashMap from the Rust std library. To provide a generic counter (any number type should work) some traits from the num-traits crate are used.

Documentation

Usage

Add the following to your Cargo.toml:

[dependencies]
countmap = "0.2"

Next, add this to your crate root:

extern crate countmap;

Now you can use a count map in your code:

extern crate countmap;
use countmap::CountMap;

fn main() {
	let map: CountMap<_, u16> = CountMap::new();
	map.insert_or_increment("foo");
	map.insert_or_increment("foo");
	map.insert_or_increment("foo");
	assert_eq!(map.get_count(&"foo"), Some(3));
}

License

Countmap is licensed under either of the following, at your option:

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages