mgechev / javascript-algorithms

💻 JavaScript implementations of computer science algorithms
https://mgechev.github.io/javascript-algorithms/
MIT License
7.83k stars 1.27k forks source link

Implemented Hash table and spec. #74

Closed JakeHP closed 9 years ago

JakeHP commented 9 years ago

Creating a PR for this so you can check it out @mgechev before we bring it in. I started off with https://github.com/mgechev/javascript-algorithms/pull/68 as a base, and did quite a bit of modification.

I'm going to add documentation also before we merge it in.

The main thing to note is an added optional (not to be used by anything other than test/spec) parameter, hashCode, to get(), put(), remove(). This is used to simulate collisions. I did this since finding keys that are different, but generate the same hash, using the javascript implementation of java's 32bitint hash function (that I brought over from https://github.com/mgechev/javascript-algorithms/pull/68) would have been a pain.

mgechev commented 9 years ago

Looks awesome, great job!

I'll merge it the way it is. If you agree about the note above you can push the change in master, if you think it might create any issues we can discuss them here.