feat: implement drop functionality

- Added `drop()` function in buckets.
- Implemented `Drop()` function for Table.
This commit is contained in:
2026-03-19 19:54:16 -04:00
parent 2bfaede2d4
commit d4acdda95b
2 changed files with 20 additions and 4 deletions

View File

@@ -111,10 +111,15 @@ func (t *Table[K, V]) Put(key K, value V) (err error) {
// Drop removes a value for a key in the table. Returns an error if its value
// cannot be removed.
//
// Deprecated: Do not use.
func (t Table[K, V]) Drop(_ K) {
panic("Not implemented")
func (t Table[K, V]) Drop(key K) (err error) {
t.bucketA.drop(key)
t.bucketB.drop(key)
if t.load() < t.minLoadFactor {
return t.resize()
}
return nil
}
// Entries returns an unordered sequence of all key-value pairs in the table.