Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 69c3a16

Browse filesBrowse files
committed
Refactor LRU Cache.
1 parent fbd7755 commit 69c3a16
Copy full SHA for 69c3a16

File tree

2 files changed

+21
-19
lines changed
Filter options

2 files changed

+21
-19
lines changed

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

Copy file name to clipboardExpand all lines: src/data-structures/lru-cache/LRUCache.js
+21-2Lines changed: 21 additions & 2 deletions
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

Copy file name to clipboardExpand all lines: src/data-structures/lru-cache/LinkedListNode.js
-17Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.