LFU the Least Frequently Used (LFU) page-replacement algorithm
| 17 | |
| 18 | // LFU the Least Frequently Used (LFU) page-replacement algorithm |
| 19 | type 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 |
| 33 | func NewLFU(capacity int) LFU { |
nothing calls this directly
no outgoing calls
no test coverage detected