Chinmay26 / HashMap-1

Basic HashMap (Hash Table) Implementation in C++

Home Page:https://medium.com/@aozturk/simple-hash-map-hash-table-implementation-in-c-931965904250#.3de167cv4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HashMap Build Status Coverage Status

Basic Hash Map Implementation in C++

Usage

Example

Define a hash function by overloading operator() for integer type key

	struct MyKeyHash {
    	unsigned long operator()(const int& k) const
    	{	
        	return k % 10;
    	}
	};

Declare a hashmap with integer type key and string type value pair

	size_t tableSize = 10;
	HashMap<int, string, tableSize, MyKeyHash> hmap;

Put a key-value pair into the hashmap

	hmap.put(1, "1");

Get the value by key; returns true if successful with value updated

	string value;
	bool result = hmap.get(2, value);

Building

This is a header only library, so no compile step is required. To use the functionality below however, you must use cmake to generate the makefiles.

mkdir build
cd build
cmake ..

Install

make install

You can also create packages in the build directory. See cpack for details, here is an example for ubuntu.

cpack -G DEB
sudo dpkg -i *.deb

Testing

From build directory:

	make test

You can also check test coverage:

	make coverage

License

Licensed under the Apache 2.0 license.

About

Basic HashMap (Hash Table) Implementation in C++

https://medium.com/@aozturk/simple-hash-map-hash-table-implementation-in-c-931965904250#.3de167cv4

License:Apache License 2.0


Languages

Language:C++ 69.6%Language:CMake 26.5%Language:Shell 3.9%