Indeed, why reinvent the wheel. If this is just an exercise, then I suggest reading the following:
Hash table - Wikipedia, the free encyclopedia