fix: public facing key/value fields in entry
All checks were successful
CI / Check PR Title (pull_request) Successful in 19s
CI / Go Lint (pull_request) Successful in 42s
CI / Markdown Lint (pull_request) Successful in 23s
CI / Makefile Lint (pull_request) Successful in 41s
CI / Unit Tests (pull_request) Successful in 41s
CI / Fuzz Tests (pull_request) Successful in 1m12s
CI / Mutation Tests (pull_request) Successful in 58s
All checks were successful
CI / Check PR Title (pull_request) Successful in 19s
CI / Go Lint (pull_request) Successful in 42s
CI / Markdown Lint (pull_request) Successful in 23s
CI / Makefile Lint (pull_request) Successful in 41s
CI / Unit Tests (pull_request) Successful in 41s
CI / Fuzz Tests (pull_request) Successful in 1m12s
CI / Mutation Tests (pull_request) Successful in 58s
This commit is contained in:
18
bucket.go
18
bucket.go
@@ -2,8 +2,8 @@ package cuckoo
|
||||
|
||||
// An Entry is a key-value pair.
|
||||
type Entry[K, V any] struct {
|
||||
key K
|
||||
value V
|
||||
Key K
|
||||
Value V
|
||||
}
|
||||
|
||||
type slot[K, V any] struct {
|
||||
@@ -30,7 +30,7 @@ func (b bucket[K, V]) get(key K) (value V, found bool) {
|
||||
}
|
||||
|
||||
slot := b.slots[b.location(key)]
|
||||
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) {
|
||||
@@ -40,7 +40,7 @@ func (b *bucket[K, V]) drop(key K) (occupied bool) {
|
||||
|
||||
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
|
||||
b.size--
|
||||
return true
|
||||
@@ -65,8 +65,8 @@ func (b bucket[K, V]) update(key K, value V) (updated bool) {
|
||||
|
||||
slot := &b.slots[b.location(key)]
|
||||
|
||||
if slot.occupied && b.compare(slot.key, key) {
|
||||
slot.value = value
|
||||
if slot.occupied && b.compare(slot.Key, key) {
|
||||
slot.Value = value
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ func (b *bucket[K, V]) insert(insertion Entry[K, V]) (evicted Entry[K, V], evict
|
||||
return insertion, true
|
||||
}
|
||||
|
||||
slot := &b.slots[b.location(insertion.key)]
|
||||
slot := &b.slots[b.location(insertion.Key)]
|
||||
|
||||
if !slot.occupied {
|
||||
slot.Entry = insertion
|
||||
@@ -87,8 +87,8 @@ func (b *bucket[K, V]) insert(insertion Entry[K, V]) (evicted Entry[K, V], evict
|
||||
return
|
||||
}
|
||||
|
||||
if b.compare(slot.key, insertion.key) {
|
||||
slot.value = insertion.value
|
||||
if b.compare(slot.Key, insertion.Key) {
|
||||
slot.Value = insertion.Value
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user