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

Method LRUCache

csharp/Linked Lists/LRUCache.cs:29–42  ·  view source on GitHub ↗
(int capacity)

Source from the content-addressed store, hash-verified

27 private readonly DoublyLinkedListNode _tail;
28
29 public LRUCache(int capacity)
30 {
31 _capacity = capacity;
32
33 // A hash map that maps keys to nodes
34 _hashMap = new Dictionary<int, DoublyLinkedListNode>();
35
36 // Initialize the head and tail dummy nodes and connect them to
37 // each other to establish a basic two-node doubly linked list.
38 _head = new DoublyLinkedListNode(-1, -1);
39 _tail = new DoublyLinkedListNode(-1, -1);
40 _head.Next = _tail;
41 _tail.Prev = _head;
42 }
43
44 public int Get(int key)
45 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected