Update hash_map_array.py

This commit is contained in:
bt3gl 2023-07-30 12:26:33 -07:00 committed by GitHub
parent 606784af38
commit 6dc689f3a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,4 +41,7 @@ class Bucket:
def remove(self, key): def remove(self, key):
for i, k in enumerate(self.bucket): for i, k in enumerate(self.bucket):
if key == k[0]: if key == k[0]:
# del is an O(n) operation, as we would copy all the i: elements
# to make it O(1) we could swap the element we want to remove
# with the last element in the bucket
del self.bucket[i] del self.bucket[i]