revert: Entry -> entry bc Put() doesnt use it
All checks were successful
CI / Check PR Title (pull_request) Successful in 31s
CI / Go Lint (pull_request) Successful in 56s
CI / Markdown Lint (pull_request) Successful in 35s
CI / Makefile Lint (pull_request) Successful in 54s
CI / Unit Tests (pull_request) Successful in 56s
CI / Fuzz Tests (pull_request) Successful in 1m25s
CI / Mutation Tests (pull_request) Successful in 1m9s
All checks were successful
CI / Check PR Title (pull_request) Successful in 31s
CI / Go Lint (pull_request) Successful in 56s
CI / Markdown Lint (pull_request) Successful in 35s
CI / Makefile Lint (pull_request) Successful in 54s
CI / Unit Tests (pull_request) Successful in 56s
CI / Fuzz Tests (pull_request) Successful in 1m25s
CI / Mutation Tests (pull_request) Successful in 1m9s
This commit is contained in:
30
subtable.go
30
subtable.go
@@ -1,13 +1,13 @@
|
||||
package cuckoo
|
||||
|
||||
// An Entry is a key-value pair.
|
||||
type Entry[K, V any] struct {
|
||||
Key K
|
||||
Value V
|
||||
// An entry is a key-value pair.
|
||||
type entry[K, V any] struct {
|
||||
key K
|
||||
value V
|
||||
}
|
||||
|
||||
type slot[K, V any] struct {
|
||||
Entry[K, V]
|
||||
entry[K, V]
|
||||
occupied bool
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ func (t *subtable[K, V]) get(key K) (value V, found bool) {
|
||||
}
|
||||
|
||||
slot := t.slots[t.location(key)]
|
||||
return slot.Value, slot.occupied && t.compare(slot.Key, key)
|
||||
return slot.value, slot.occupied && t.compare(slot.key, key)
|
||||
}
|
||||
|
||||
func (t *subtable[K, V]) drop(key K) (occupied bool) {
|
||||
@@ -40,7 +40,7 @@ func (t *subtable[K, V]) drop(key K) (occupied bool) {
|
||||
|
||||
slot := &t.slots[t.location(key)]
|
||||
|
||||
if slot.occupied && t.compare(slot.Key, key) {
|
||||
if slot.occupied && t.compare(slot.key, key) {
|
||||
slot.occupied = false
|
||||
t.size--
|
||||
return true
|
||||
@@ -65,34 +65,34 @@ func (t *subtable[K, V]) update(key K, value V) (updated bool) {
|
||||
|
||||
slot := &t.slots[t.location(key)]
|
||||
|
||||
if slot.occupied && t.compare(slot.Key, key) {
|
||||
slot.Value = value
|
||||
if slot.occupied && t.compare(slot.key, key) {
|
||||
slot.value = value
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *subtable[K, V]) insert(insertion Entry[K, V]) (evicted Entry[K, V], eviction bool) {
|
||||
func (t *subtable[K, V]) insert(insertion entry[K, V]) (evicted entry[K, V], eviction bool) {
|
||||
if t.capacity == 0 {
|
||||
return insertion, true
|
||||
}
|
||||
|
||||
slot := &t.slots[t.location(insertion.Key)]
|
||||
slot := &t.slots[t.location(insertion.key)]
|
||||
|
||||
if !slot.occupied {
|
||||
slot.Entry = insertion
|
||||
slot.entry = insertion
|
||||
slot.occupied = true
|
||||
t.size++
|
||||
return
|
||||
}
|
||||
|
||||
if t.compare(slot.Key, insertion.Key) {
|
||||
slot.Value = insertion.Value
|
||||
if t.compare(slot.key, insertion.key) {
|
||||
slot.value = insertion.value
|
||||
return
|
||||
}
|
||||
|
||||
insertion, slot.Entry = slot.Entry, insertion
|
||||
insertion, slot.entry = slot.entry, insertion
|
||||
return insertion, true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user