From 961d49c532151870822188bc6e4c84a271fbbf81 Mon Sep 17 00:00:00 2001 From: Oleksandr Mateshchuk Date: Tue, 27 Oct 2026 14:04:58 +0000 Subject: [PATCH] Aktualizovat u7/hash_table.py --- u7/hash_table.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/u7/hash_table.py b/u7/hash_table.py index c5ca737..f90f5e4 100644 --- a/u7/hash_table.py +++ b/u7/hash_table.py @@ -1,4 +1,3 @@ - class HashTable: def __init__(self, capacity=10): """Vytvor prázdnu tabuľku s kladnou celočíselnou kapacitou.""" @@ -57,6 +56,17 @@ class HashTable: if not isinstance(key, str): raise TypeError("Key must be a string") + try: + index = self.probe(key) + except RuntimeError: + return False + + item = self._table[index] + return ( + item is not None + and item is not self._DELETED + and item[0] == key + ) def __len__(self): return self._size