MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / keys

Method keys

data_structures/hashing/hash_table.py:25–49  ·  view source on GitHub ↗

The keys function returns a dictionary containing the key value pairs. key being the index number in hash table and value being the data value. Examples: 1. creating HashTable with size 10 and inserting 3 elements >>> ht = HashTable(10) >>> ht.insert

(self)

Source from the content-addressed store, hash-verified

23 self._keys: dict = {}
24
25 def keys(self):
26 """
27 The keys function returns a dictionary containing the key value pairs.
28 key being the index number in hash table and value being the data value.
29
30 Examples:
31 1. creating HashTable with size 10 and inserting 3 elements
32 >>> ht = HashTable(10)
33 >>> ht.insert_data(10)
34 >>> ht.insert_data(20)
35 >>> ht.insert_data(30)
36 >>> ht.keys()
37 {0: 10, 1: 20, 2: 30}
38
39 2. creating HashTable with size 5 and inserting 5 elements
40 >>> ht = HashTable(5)
41 >>> ht.insert_data(5)
42 >>> ht.insert_data(4)
43 >>> ht.insert_data(3)
44 >>> ht.insert_data(2)
45 >>> ht.insert_data(1)
46 >>> ht.keys()
47 {0: 5, 4: 4, 3: 3, 2: 2, 1: 1}
48 """
49 return self._keys
50
51 def balanced_factor(self):
52 return sum(1 for slot in self.values if slot is not None) / (

Callers 7

partition_graphFunction · 0.80
mainFunction · 0.80
city_selectFunction · 0.80
create_edgeFunction · 0.80
construct_graphFunction · 0.80
get_verticesMethod · 0.80
find_unit_clausesFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected