Generates hash for the given key value Examples: Creating HashTable with size 5 >>> ht = HashTable(5) >>> ht.hash_function(10) 0 >>> ht.hash_function(20) 0 >>> ht.hash_function(4) 4 >>> ht.hash_function(18)
(self, key)
| 54 | ) |
| 55 | |
| 56 | def hash_function(self, key): |
| 57 | """ |
| 58 | Generates hash for the given key value |
| 59 | |
| 60 | Examples: |
| 61 | |
| 62 | Creating HashTable with size 5 |
| 63 | >>> ht = HashTable(5) |
| 64 | >>> ht.hash_function(10) |
| 65 | 0 |
| 66 | >>> ht.hash_function(20) |
| 67 | 0 |
| 68 | >>> ht.hash_function(4) |
| 69 | 4 |
| 70 | >>> ht.hash_function(18) |
| 71 | 3 |
| 72 | >>> ht.hash_function(-18) |
| 73 | 2 |
| 74 | >>> ht.hash_function(18.5) |
| 75 | 3.5 |
| 76 | >>> ht.hash_function(0) |
| 77 | 0 |
| 78 | >>> ht.hash_function(-0) |
| 79 | 0 |
| 80 | """ |
| 81 | return key % self.size_table |
| 82 | |
| 83 | def _step_by_step(self, step_ord): |
| 84 | print(f"step {step_ord}") |
no outgoing calls
no test coverage detected