MCPcopy
hub / github.com/trekhleb/javascript-algorithms / get

Method get

src/data-structures/lru-cache/LRUCache.js:50–55  ·  view source on GitHub ↗

* Returns the cached value by its key. * Time complexity: O(1) in average. * @param {string} key * @returns {any}

(key)

Source from the content-addressed store, hash-verified

48 * @returns {any}
49 */
50 get(key) {
51 if (this.nodesMap[key] === undefined) return undefined;
52 const node = this.nodesMap[key];
53 this.promote(node);
54 return node.val;
55 }
56
57 /**
58 * Sets the value to cache by its key.

Callers 11

LRUCache.test.jsFile · 0.45
comparePriorityMethod · 0.45
getChildMethod · 0.45
addChildMethod · 0.45
isNodeRedMethod · 0.45
isNodeBlackMethod · 0.45
swapNodeColorsMethod · 0.45
isValidFunction · 0.45

Calls 1

promoteMethod · 0.95

Tested by

no test coverage detected