feat: implement drop functionality
- Added `drop()` function in buckets. - Implemented `Drop()` function for Table.
This commit is contained in:
11
bucket.go
11
bucket.go
@@ -26,6 +26,17 @@ func (b bucket[K, V]) get(key K) (value V, found bool) {
|
||||
return slot.value, slot.occupied && b.compare(slot.key, key)
|
||||
}
|
||||
|
||||
func (b bucket[K, V]) drop(key K) (occupied bool) {
|
||||
slot := &b.slots[b.location(key)]
|
||||
|
||||
if slot.occupied && b.compare(slot.key, key) {
|
||||
slot.occupied = false
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (b *bucket[K, V]) resize(capacity uint64) {
|
||||
b.slots = make([]slot[K, V], capacity)
|
||||
b.capacity = capacity
|
||||
|
||||
Reference in New Issue
Block a user