任何人都可以帮我修复我的put函数,以便在哈希表中插入一个值,它返回的哈希表完全没有了
class BasicHashTable:
def __init__(self,size=7):
self.size = size
self.slots = [None] * self.size
def hash_function(self, key):
return key%len(self.slots)
def rehash(self, old_pos):
return (old_pos + 1) % self.size
def put(self, key):
hash_value = key%len(self.slots)
probe_seq=[]
insert_pos=hash_value
probe_seq+=[insert_pos]
probes=1
while(self.slots[insert_pos]!=None):
probes+=1
insert_pos=(insert_pos+1)%len(self.slots)
probe_seq+=[insert_pos]
self.slots[insert_pos]=key
return insert_pos