Esempio n. 1
0
 def __seperate_chainIns(self, item, searchkey):
     ''' insert an item into the given doubly linked
     chain if the given item isn't a linked chain yet
     a new linked chain will be created.'''
     if isinstance(self.__table[self.__h(searchkey)], type(doubly_linked_chain.doubly_linked_chain())):
         self.__table[self.__h(searchkey)].insert(self.__item(item, searchkey), searchkey)
     else:
         
         temp = self.__table[self.__h(searchkey)]
         
         self.__table[self.__h(searchkey)] = doubly_linked_chain.doubly_linked_chain()
         self.__table[self.__h(searchkey)].insert(temp, temp.searchkey)
         self.__table[self.__h(searchkey)].insert(self.__item(item, searchkey), searchkey)
Esempio n. 2
0
 def remove(self,searchkey):
     ''' removes the item with the given searchkey.
     If the place is occupied but doesn't equal the
     searchkey the remove method of the given probe type will be called.'''
     if isinstance(self.__table[self.__h(searchkey)], type(doubly_linked_chain.doubly_linked_chain())):
         self.__probeRem(searchkey)
     elif self.__table[self.__h(searchkey)].searchkey == None:
Esempio n. 3
0
 def __seperate_chainGet(self, searchkey):
     ''' returns the item with the specified searchkey ''' 
     if isinstance(self.__table[self.__h(searchkey)], type(doubly_linked_chain.doubly_linked_chain())):
         tmp = self.__table[self.__h(searchkey)].getNode(searchkey)
         if tmp == None:
             return -1
         else:
             return tmp.item.item
     else:
         return self.__table[self.__h(searchkey)].item
Esempio n. 4
0
 def insert(self, item, searchkey):
     ''' insert an item to the table if the place is
     already occupied the insert method of the chosen
     probe type will be called.'''
     if isinstance(self.__table[self.__h(searchkey)], type(doubly_linked_chain.doubly_linked_chain())):
         self.__probeIns(item, searchkey)
     elif self.__table[self.__h(searchkey)].searchkey == None:
         self.__table[self.__h(searchkey)] = self.__item(item, searchkey)
     else:
         self.__probeIns(item, searchkey)
     self.__length += 1
Esempio n. 5
0
 def __seperate_chainRem(self, searchkey):
     ''' Removes the item with the given searchkey from a
     linked chain if the chain only contains one item
     afterwards it will be turned into an item again. '''
     if isinstance(self.__table[self.__h(searchkey)], type(doubly_linked_chain.doubly_linked_chain())):
         if self.__table[self.__h(searchkey)].length == 1:
             self.__table[self.__h(searchkey)] = 0
             return
         self.__table[self.__h(searchkey)].remove(searchkey)
         if self.__table[self.__h(searchkey)].length == 1:
             tmp = self.__table[self.__h(searchkey)].headPtr.next.item
             self.__table[self.__h(searchkey)] = tmp     
     else:
         self.__table[self.__h(searchkey)] = self.__item(0, None)