MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / LFU

Struct LFU

cache/lfu.go:19–30  ·  view source on GitHub ↗

LFU the Least Frequently Used (LFU) page-replacement algorithm

Source from the content-addressed store, hash-verified

17
18// LFU the Least Frequently Used (LFU) page-replacement algorithm
19type LFU struct {
20 len int // length
21 cap int // capacity
22 minFreq int // The element that operates least frequently in LFU
23
24 // key: key of element, value: value of element
25 itemMap map[string]*list.Element
26
27 // key: frequency of possible occurrences of all elements in the itemMap
28 // value: elements with the same frequency
29 freqMap map[int]*list.List
30}
31
32// NewLFU init the LFU cache with capacity
33func NewLFU(capacity int) LFU {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected