* Adds a node immediately after the head (marks as most recently used). * Used when inserting new items or when an item is accessed. * PRECONDITION: node must be disconnected (prev/next should be null)
(node: LRUNode<T>)
| 75 | * PRECONDITION: node must be disconnected (prev/next should be null) |
| 76 | */ |
| 77 | private addToHead(node: LRUNode<T>): void { |
| 78 | node.prev = this.head |
| 79 | node.next = this.head.next |
| 80 | // head.next is always non-null (points to tail or another node) |
| 81 | this.head.next!.prev = node |
| 82 | this.head.next = node |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Removes a node from its current position in the doubly-linked list. |
no outgoing calls
no test coverage detected