MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / NewLFU

Function NewLFU

cache/lfu.go:33–41  ·  view source on GitHub ↗

NewLFU init the LFU cache with capacity

(capacity int)

Source from the content-addressed store, hash-verified

31
32// NewLFU init the LFU cache with capacity
33func NewLFU(capacity int) LFU {
34 return LFU{
35 len: 0,
36 cap: capacity,
37 minFreq: math.MaxInt,
38 itemMap: make(map[string]*list.Element),
39 freqMap: make(map[int]*list.List),
40 }
41}
42
43// initItem to init item for LFU
44func initItem(k string, v any, f int) item {

Callers 1

TestLFUFunction · 0.92

Calls

no outgoing calls

Tested by 1

TestLFUFunction · 0.74