(self, capacity: int)
| 7 | |
| 8 | class LRUCache: |
| 9 | def __init__(self, capacity: int): |
| 10 | self.capacity = capacity |
| 11 | # A hash map that maps keys to nodes. |
| 12 | self.hashmap = {} |
| 13 | # Initialize the head and tail dummy nodes and connect them to |
| 14 | # each other to establish a basic two-node doubly linked list. |
| 15 | self.head = DoublyLinkedListNode(-1, -1) |
| 16 | self.tail = DoublyLinkedListNode(-1, -1) |
| 17 | self.head.next = self.tail |
| 18 | self.tail.prev = self.head |
| 19 | |
| 20 | def get(self, key: int) -> int: |
| 21 | if key not in self.hashmap: |
nothing calls this directly
no test coverage detected