Can anyone give a good tutorial of how to create a hash table by hashing keys to values and avoiding/dealing with collisions in python? I have seen lots of little bits of code here and there, but I was wondering if someone could assist me.
Basically:
- Create the table
- Choose a hash function and hash the keys into the table
- Deal with collisions
- Perform lookups on said table
Have you tried customizing your object to work with the built in dict type? It IS a hash table. To customize hashing, all you need to do is make sure your key objects are Hashable:
Now Foo can be a key for a dict