I'm writing a program to form hash tables of different sizes with linear probing. In my ADT for the linear probing I have a function def insert ( ) which is called from my main script from the following function:
def insertHashTable( loadNum, hashTable ):
i = 0
while i < ((loadNum*size)-1):
hashTable.insert(data[i],data[i])
i = i + 1
return hashTable
The error itself is from this function that is called from insertHashTable( )
def insert( self, key, value ):
( found, slot ) = self._findSlot( key ) #ERROR HERE
if not found :
self._table[slot] = _MapEntry( key, value ) #custom datatype
self._count += 1
return not found
I get the nonetype error on the second line of this code. Finally, _findSlot( ) is the following:
def _findSlot( self, key ):
startLoc = self._hash1( key )
self.slotsAccessed += 1
if self._table.__getitem__( startLoc ) == None:
return (False, startLoc)
else:
c = 0
while (c+startLoc) < (self._size -1):
if self._table[startLoc+c] == None:
return (False, startLoc+c)
elif self._table.__getitem__( startLoc ).key == key:
return (True, startLoc+c)
c = c + 1
self.slotsAccessed += c
I'm not sure why there would be such an error in the insertHashTable( ) function, seeing as there is no iteration happening with the key.
I do however know my hashtable has 'None' in every slot at initialization of the table, maybe there's some issue with that?