Mark As Completed Discussion

Now, when we new up a Cache instance, we'll want certain things predefined in the constructor. Let's flesh that out:

  1. We'll need a reference to the capacity
  2. A count for the number of keys we have
  3. The cache via a hash table itself
  4. References to the heads and tails of the doubly linked list
1class Cache {
2  constructor(capacity) {
3    this.count = 0;
4    this.capacity = capacity;
5    this.cache = {};
6    this.head = new DLinkedNode();
7    this.head.pre = null;
8    this.tail = new DLinkedNode();
9    this.tail.next = null;
10    this.head.next = this.tail;
11    this.tail.pre = this.head;
12  }
13}