Skip to content

Commit 69c3a16

Browse files
committed
Refactor LRU Cache.
1 parent fbd7755 commit 69c3a16

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/data-structures/lru-cache/LRUCache.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
1-
/* eslint-disable no-param-reassign */
2-
import LinkedListNode from './LinkedListNode';
1+
/* eslint-disable no-param-reassign, max-classes-per-file */
2+
3+
/**
4+
* Simple implementation of the Doubly-Linked List Node
5+
* that is used in LRUCache class below.
6+
*/
7+
class LinkedListNode {
8+
/**
9+
* Creates a doubly-linked list node.
10+
* @param {string} key
11+
* @param {any} val
12+
* @param {LinkedListNode} prev
13+
* @param {LinkedListNode} next
14+
*/
15+
constructor(key, val, prev = null, next = null) {
16+
this.key = key;
17+
this.val = val;
18+
this.prev = prev;
19+
this.next = next;
20+
}
21+
}
322

423
/**
524
* Implementation of the LRU (Least Recently Used) Cache

src/data-structures/lru-cache/LinkedListNode.js

-17
This file was deleted.

0 commit comments

Comments
 (0)