Package org.eclipse.jgit.util
Class LRUMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
org.eclipse.jgit.util.LRUMap<K,V>
- Type Parameters:
K
- the type of keys maintained by this mapV
- the type of mapped values
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<K,
V>
Map with only up to n entries. If a new entry is added so that the map
contains more than those n entries the least-recently used entry is removed
from the map.
- Since:
- 5.4
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
private static final long
-
Constructor Summary
ConstructorsConstructorDescriptionLRUMap
(int initialCapacity, int limit) Constructs an empty map which may contain at most the given amount of entries. -
Method Summary
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, values
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
limit
private final int limit
-
-
Constructor Details
-
LRUMap
public LRUMap(int initialCapacity, int limit) Constructs an empty map which may contain at most the given amount of entries.- Parameters:
initialCapacity
- the initial capacitylimit
- the number of entries the map should have at most
-
-
Method Details
-
removeEldestEntry
- Overrides:
removeEldestEntry
in classLinkedHashMap<K,
V>
-