Retrieve the value for a given key. Args: key: The key to look up. Returns: The value associated with the key, or None if not found.
(self, key: int)
| 68 | raise ValueError("Table is full") |
| 69 | |
| 70 | def get(self, key: int) -> object | None: |
| 71 | """Retrieve the value for a given key. |
| 72 | |
| 73 | Args: |
| 74 | key: The key to look up. |
| 75 | |
| 76 | Returns: |
| 77 | The value associated with the key, or None if not found. |
| 78 | """ |
| 79 | initial_hash = hash_ = self.hash(key) |
| 80 | while True: |
| 81 | if self._keys[hash_] is self._empty: |
| 82 | return None |
| 83 | elif self._keys[hash_] == key: |
| 84 | return self._values[hash_] |
| 85 | |
| 86 | hash_ = self._rehash(hash_) |
| 87 | if initial_hash == hash_: |
| 88 | return None |
| 89 | |
| 90 | def del_(self, key: int) -> None: |
| 91 | """Delete a key-value pair. |