Get next index. Implements linear open addressing. >>> HashMap(5)._get_next_ind(3) 4 >>> HashMap(5)._get_next_ind(5) 1 >>> HashMap(5)._get_next_ind(6) 2 >>> HashMap(5)._get_next_ind(9) 0
(self, ind: int)
| 51 | return hash(key) % len(self._buckets) |
| 52 | |
| 53 | def _get_next_ind(self, ind: int) -> int: |
| 54 | """ |
| 55 | Get next index. |
| 56 | |
| 57 | Implements linear open addressing. |
| 58 | >>> HashMap(5)._get_next_ind(3) |
| 59 | 4 |
| 60 | >>> HashMap(5)._get_next_ind(5) |
| 61 | 1 |
| 62 | >>> HashMap(5)._get_next_ind(6) |
| 63 | 2 |
| 64 | >>> HashMap(5)._get_next_ind(9) |
| 65 | 0 |
| 66 | """ |
| 67 | return (ind + 1) % len(self._buckets) |
| 68 | |
| 69 | def _try_set(self, ind: int, key: KEY, val: VAL) -> bool: |
| 70 | """ |