fix: drop() decrements bucket size
This commit is contained in:
@@ -26,11 +26,12 @@ func (b bucket[K, V]) get(key K) (value V, found bool) {
|
|||||||
return slot.value, slot.occupied && b.compare(slot.key, key)
|
return slot.value, slot.occupied && b.compare(slot.key, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b bucket[K, V]) drop(key K) (occupied bool) {
|
func (b *bucket[K, V]) drop(key K) (occupied bool) {
|
||||||
slot := &b.slots[b.location(key)]
|
slot := &b.slots[b.location(key)]
|
||||||
|
|
||||||
if slot.occupied && b.compare(slot.key, key) {
|
if slot.occupied && b.compare(slot.key, key) {
|
||||||
slot.occupied = false
|
slot.occupied = false
|
||||||
|
b.size--
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user