MCPcopy
hub / github.com/TheAlgorithms/JavaScript / insert

Method insert

Cache/LFUCache.js:40–48  ·  view source on GitHub ↗

* @method insert * @description - Add new CacheNode into HashSet by the frequency * @param {CacheNode} node

(node)

Source from the content-addressed store, hash-verified

38 * @param {CacheNode} node
39 */
40 insert(node) {
41 const { frequency } = node
42
43 if (!this.has(frequency)) {
44 this.set(frequency, new Set())
45 }
46
47 this.get(frequency).add(node)
48 }
49}
50
51class LFUCache {

Callers 2

refreshMethod · 0.95
setMethod · 0.45

Calls 4

hasMethod · 0.45
setMethod · 0.45
addMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected