Skip to content

Chinmay26/HashMap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

HashMap

This is C++ implementation of generic Hash table which uses linear probing to resolve collisions. This solution is inspired the standard C++ unordered_map & Boost unordered_map implmentation. This was a side-project. Obviously, this is not even close to being production ready.

Example Usage

Declare your custom hash function based on input data type

struct MyHashCompute {
	size_t operator()(const string &key, const int  &hashSize=1000) const
	{
		return std::hash<std::string>() (key) % hashSize;
	}
};

Declare your custom hash function

MyHashMap<std::string,int,MyHashCompute> hmap(5);

Use customary hash functions

res =  hmap.set("coursera",2012);
res = hmap.set("airware",2011);

val = hmap.get("coursera");
val = hmap.get("flipboard"); \\ raises exception

val = hmap.delete_key("coursera");

For more documentation, refer here.

About

Custom C++ Implementation of Hash table

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages