func NewWithSize[K comparable, V any]()

in lru.go [122:144]


func NewWithSize[K comparable, V any](capacity, size uint32, hash HashKeyCallback[K]) (
	*LRU[K, V], error) {
	if capacity == 0 {
		return nil, errors.New("capacity must be positive")
	}
	if size == emptyBucket {
		return nil, fmt.Errorf("size must not be %#X", size)
	}
	if size < capacity {
		return nil, fmt.Errorf("size (%d) is smaller than capacity (%d)", size, capacity)
	}
	if hash == nil {
		return nil, errors.New("hash function must be set")
	}

	buckets := make([]uint32, size)
	elements := make([]element[K, V], size)

	var lru LRU[K, V]
	initLRU(&lru, capacity, size, hash, buckets, elements)

	return &lru, nil
}