Ejemplo n.º 1
0
    def update(self, key, data):
        index = key % self.tablesize
        if self.hashtable[index] is not None:
            if self.hashtable[index].contains(key) is False:
                raise Exeption.NotFoundException()

            self.hashtable[index].update(key, data)
        else:
            raise Exeption.NotFoundException()
Ejemplo n.º 2
0
    def find(self, key):
        index = key % self.tablesize

        if self.hashtable[index] is not None:
            if self.hashtable[index].contains(key) is False:
                raise Exeption.NotFoundException()
            return self.hashtable[index].find(key)

        else:
            raise Exeption.NotFoundException()
Ejemplo n.º 3
0
 def find(self,key):
     temp=self.head
     while temp is not None:
         if temp.key is key:
             return temp.data
         temp=temp.next
     
     raise Exeption.NotFoundException()
Ejemplo n.º 4
0
 def update(self,key,data):
     temp=self.head
     while temp is not None:
         if temp.key is key:
             temp.data=data
             return
         temp=temp.next
     raise Exeption.NotFoundException()
Ejemplo n.º 5
0
 def remove(self,key):
     #this is an special case which is removing head of the list
     if self.head.key is key:
         self.head=self.head.next
         return
     temp=self.head
     pre=None
     while temp is not None:
         if temp.key is key:
             pre.next=temp.next
             return
         pre=temp
         temp=temp.next
     Exeption.NotFoundException()
Ejemplo n.º 6
0
 def __getitem__(self, key):
     index = key % self.tablesize
     if self.hashtable[index]:
         return self.hashtable[index].find(key)
     else:
         raise Exeption.NotFoundException()
Ejemplo n.º 7
0
 def remove(self, key):
     index = key % self.tablesize
     if self.hashtable[index] is not None:
         if self.hashtable[index].contains(key) is False:
             raise Exeption.NotFoundException()
         self.hashtable[index].remove(key)