Esempio n. 1
0
 def __get_value_at_key(self, bucket: LinkedList, key):
     current = bucket.get_head()
     while current:
         if current.value[0] == key:
             return current.value[1]
         current = current.next
     return None
Esempio n. 2
0
    def __bucket_contains(self, bucket: LinkedList, item: tuple):
        current = bucket.get_head()
        while current:
            if current.value[0] == item[0]:
                return True
            current = current.next

        return False
Esempio n. 3
0
 def __add_to_bucket(self, bucket: LinkedList, item: tuple) -> None:
     if not self.__bucket_contains(bucket, item):
         bucket.append(item)
     else:
         current = bucket.get_head()
         while current:
             if current.value[0] == item[0]:
                 bucket.remove_value(current.value)
             current = current.next
         bucket.append(item)
Esempio n. 4
0
 def __get(self, bucket: LinkedList, what):
     output = []
     current = bucket.get_head()
     while current:
         if what == "keys":
             output.append(current.value[0])
         elif what == "values":
             output.append(current.value[1])
         current = current.next
     return output