mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-30 04:36:08 -04:00
Update hash_map_array.py
This commit is contained in:
parent
606784af38
commit
6dc689f3a0
@ -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]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user