Last active
March 24, 2019 15:15
-
-
Save AdamGold/8b2db46eca75327a97b9cace21d1d2e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | |
while found and not entry.compare_hash(found): | |
index = (index + 1) % 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