Hashmap built out in Haskell. Pretty self explanatory.
Hashmaps (or hash tables) are efficent data structures that allow for O(1) access using keys. They are essentially a wrapper around an array, but allow for access with strings rather than simply integer indixes. This is accomplished by taking advantage of a hash function, which tries to assign each input string (key) with a unique array.
| Function | Description |
|---|---|
| djb2Hash | A pretty efficent and effective hash function with rare collisions. See more |
| createHashMap | Creates a hashmap with a given default size and desired hash function (presumably djb2Hash) |
| lookupKey | Returns the desired value when given a key and specified hashmap |
| insertKey | Add a new key-pair value into the hashmap |
| insertWith | Add a new key-pair value while applying a specified funcion to the value |
First build the project:
cabal build Then, run the tests:
cabal runYou output should look something like this:
Cases: 5 Tried: 5 Errors: 0 Failures: 0
MIT