Created
January 25, 2019 16:11
-
-
Save deque-blog/9ba220d4666f055f2eeb8d2c4d53b28e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LRUCache<K, V> extends LinkedHashMap<K, V> { | |
private final int capacity; | |
public LRUCache(int capacity) { | |
this.capacity = capacity; | |
} | |
@Override | |
protected boolean removeEldestEntry(Map.Entry<K, V> oldest) { | |
return size() > capacity; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment