Skip to content

Instantly share code, notes, and snippets.

@AdamGold
Last active March 28, 2019 13:12
Show Gist options
  • Save AdamGold/548bf46b3e223d6384361833b47b7def to your computer and use it in GitHub Desktop.
Save AdamGold/548bf46b3e223d6384361833b47b7def to your computer and use it in GitHub Desktop.
def __getitem__(self, key: str) -> Entry:
"""subscript method - object[key]
use hashing function to find the index"""
entry = Entry(key)
index = entry.hash % self.actual_size
found = self.entries[index]
if found == None:
raise KeyError
return found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment