in lru.go [146:163]
func initLRU[K comparable, V any](lru *LRU[K, V], capacity, size uint32, hash HashKeyCallback[K],
buckets []uint32, elements []element[K, V]) {
lru.cap = capacity
lru.size = size
lru.hash = hash
lru.buckets = buckets
lru.elements = elements
// If the size is 2^N, we can avoid costly divisions.
if bits.OnesCount32(lru.size) == 1 {
lru.mask = lru.size - 1
}
// Mark all slots as free.
for i := range lru.buckets {
lru.buckets[i] = emptyBucket
}
}