Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hash Table 7
# @param {string} key
# @returns {*}
def get(self, key):
bucketLinkedList = self.buckets[self.hash(key)]
# custom linkedlist find
currentNode = bucketLinkedList.head
while not currentNode == None:
for k in currentNode.value:
if k == key:
return currentNode.value[k]
currentNode = currentNode.next
return None
# @param {string} key
# @returns {*}
def delete(self, key):
keyHash = self.hash(key)
del self.keys[key]
bucketLinkedList = self.buckets[keyHash]
# custom linkedlist find
node = None
currentNode = bucketLinkedList.head
while not currentNode == None and node == None:
for k in currentNode.value:
if k == key:
node = currentNode
break
currentNode = currentNode.next
if not node == None:
return bucketLinkedList.delete(node.value)
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.