organization in the src structure, modification of README

This commit is contained in:
Mari Wahl 2015-01-06 18:30:04 -05:00
parent c2ca11f247
commit 6afe96fa4d
165 changed files with 64 additions and 184 deletions

View file

@ -0,0 +1,34 @@
#!/usr/bin/env python
__author__ = "bt3"
class HashTable(object):
def __init__(self, slots=10):
self.slots = slots
self.table = []
self.__create_table()
def __hash_key(self, value):
return hash(value)%self.slots
def __create_table(self):
for i in range(self.slots):
self.table.append([])
def add_item(self, value):
key = self.__hash_key(value)
self.table[key].append(value)
def print_table(self):
for key in range(len(self.table)):
print "Key is %s, value is %s." %(key, self.table[key])
if __name__ == '__main__':
dic = HashTable(5)
for i in range(1, 40, 2):
dic.add_item(i)
dic.print_table()