MCPcopy Create free account
hub / github.com/ByteByteGoHq/coding-interview-patterns / Get

Method Get

csharp/Linked Lists/LRUCache.cs:44–55  ·  view source on GitHub ↗
(int key)

Source from the content-addressed store, hash-verified

42 }
43
44 public int Get(int key)
45 {
46 if (!_hashMap.ContainsKey(key))
47 return -1;
48
49 // To make this key the most recently used, remove its node and
50 // re-add it to the tail of the linked list.
51 removeNode(_hashMap[key]);
52 addToTail(_hashMap[key]);
53
54 return _hashMap[key].Val;
55 }
56
57 public void Put(int key, int value)
58 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected