| 41 | } |
| 42 | |
| 43 | int get(int key) { |
| 44 | if (hashmap.find(key) == hashmap.end()) { |
| 45 | return -1; |
| 46 | } |
| 47 | // To make this key the most recently used, remove its node and |
| 48 | // re-add it to the tail of the linked list. |
| 49 | removeNode(hashmap[key]); |
| 50 | addToTail(hashmap[key]); |
| 51 | return hashmap[key]->val; |
| 52 | } |
| 53 | |
| 54 | void put(int key, int val) { |
| 55 | // If a node with this key already exists, remove it from the |
no test coverage detected