MCPcopy
hub / github.com/TheAlgorithms/Go / insertMap

Method insertMap

cache/lfu.go:107–117  ·  view source on GitHub ↗

insertMap insert item in map

(obj item)

Source from the content-addressed store, hash-verified

105
106// insertMap insert item in map
107func (c *LFU) insertMap(obj item) {
108 // add in freqMap
109 l, ok := c.freqMap[obj.freq]
110 if !ok {
111 l = list.New()
112 c.freqMap[obj.freq] = l
113 }
114 e := l.PushFront(obj)
115 // update or add the value of itemMap key to e
116 c.itemMap[obj.key] = e
117}
118
119// eliminate clear the least frequently operated element
120func (c *LFU) eliminate() {

Callers 2

PutMethod · 0.95
increaseFreqMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected