java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
net.i2p.router.web.helpers.TunnelRenderer.BoundedCache<K,V>
- Type Parameters:
K- the key type of the cached entriesV- the value type stored under each key
- All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>, SequencedMap<K, V>
- Enclosing class:
TunnelRenderer
A bounded LRU cache extending LinkedHashMap with computeIfAbsent support.
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intEntries the cache holds before dropping the oldest.Constructor Summary
ConstructorsMethod Summary
Public MethodsMethods inherited from class LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, newLinkedHashMap, putFirst, putLast, replaceAll, reversed, sequencedEntrySet, sequencedKeySet, sequencedValues, valuesMethods inherited from class HashMap
compute, computeIfPresent, containsKey, isEmpty, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class AbstractMap
equals, hashCode, toStringMethods inherited from interface SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry
Field Details
_maxSize
private final int _maxSizeEntries the cache holds before dropping the oldest.
Constructor Details
BoundedCache
public BoundedCache(int maxSize) Builds a cache with a size limit.- Parameters:
maxSize- the entries to keep
Method Details
removeEldestEntry
- Overrides:
removeEldestEntryin classLinkedHashMap<K,V>
clone
computeIfAbsent