Skip to content

Commit

Permalink
Refactor LRU Cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
trekhleb committed Jan 24, 2023
1 parent fbd7755 commit 69c3a16
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
23 changes: 21 additions & 2 deletions src/data-structures/lru-cache/LRUCache.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
/* eslint-disable no-param-reassign */
import LinkedListNode from './LinkedListNode';
/* eslint-disable no-param-reassign, max-classes-per-file */

/**
* Simple implementation of the Doubly-Linked List Node
* that is used in LRUCache class below.
*/
class LinkedListNode {
/**
* Creates a doubly-linked list node.
* @param {string} key
* @param {any} val
* @param {LinkedListNode} prev
* @param {LinkedListNode} next
*/
constructor(key, val, prev = null, next = null) {
this.key = key;
this.val = val;
this.prev = prev;
this.next = next;
}
}

/**
* Implementation of the LRU (Least Recently Used) Cache
Expand Down
17 changes: 0 additions & 17 deletions src/data-structures/lru-cache/LinkedListNode.js

This file was deleted.

0 comments on commit 69c3a16

Please sign in to comment.