Updates the cache from the old hash to the new one. This maintains the index cache, which allows O(1) indexing and existence checks :param prev_hash: The hash to update :type prev_hash: int :param prev_hash: The new hash to update to :type ne
(self, prev_hash: int, new_hash: int)
| 100 | super().append(item) |
| 101 | |
| 102 | def update_cache(self, prev_hash: int, new_hash: int) -> None: |
| 103 | """ |
| 104 | Updates the cache from the old hash to the new one. |
| 105 | This maintains the index cache, which allows O(1) indexing and |
| 106 | existence checks |
| 107 | |
| 108 | :param prev_hash: The hash to update |
| 109 | :type prev_hash: int |
| 110 | :param prev_hash: The new hash to update to |
| 111 | :type new_hash: int |
| 112 | """ |
| 113 | try: |
| 114 | idx = self._relation_cache.pop(prev_hash) |
| 115 | self._relation_cache[new_hash] = idx |
| 116 | except KeyError: |
| 117 | pass |
| 118 | |
| 119 | def index(self, item: T, *args: Any) -> int: |
| 120 | """ |