Skip to content

Instantly share code, notes, and snippets.

@graphoarty
Created February 9, 2019 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graphoarty/d7769add0b76b051844f82ec068e5a88 to your computer and use it in GitHub Desktop.
Save graphoarty/d7769add0b76b051844f82ec068e5a88 to your computer and use it in GitHub Desktop.
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