Least Recently Used (LRU) cache.
This LRUCache implemented base on original data structure Map.
When trying to add a new key-value pair, if cache.size == cache.capacity, the Least Recently Used key is removed.
The size of this LRU is also a property.
Property capacity is allowed to be reset, Least Recently Used keys will be removed when capacity is set to smaller one.
Checklist
[x] Your branch is up-to-date with the base branch
[x] You've included at least one test if this is a new feature
Description of new feature, or changes
Least Recently Used (LRU) cache. This LRUCache implemented base on original data structure
Map
. When trying to add a new key-value pair, if cache.size == cache.capacity, the Least Recently Used key is removed. The size of this LRU is also a property. Propertycapacity
is allowed to be reset, Least Recently Used keys will be removed when capacity is set to smaller one.Checklist
Related Issues and Discussions
implement https://github.com/manrajgrover/algorithms-js/issues/17
People to notify
@manrajgrover