Package jadex.commons.collection
Class LRU<K,V>
- java.lang.Object
 - 
- java.util.AbstractMap<K,V>
 - 
- java.util.HashMap<K,V>
 - 
- java.util.LinkedHashMap<K,V>
 - 
- jadex.commons.collection.LRU<K,V>
 
 
 
 
 
- 
- All Implemented Interfaces:
 java.io.Serializable,java.lang.Cloneable,java.util.Map<K,V>
public class LRU<K,V> extends java.util.LinkedHashMap<K,V>A least recently used map.- See Also:
 - Serialized Form
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected ILRUEntryCleanercleanerThe entry cleaner (for performing cleanup code on removed entries).protected intmaxThe maximum number of entries. 
- 
Constructor Summary
Constructors Constructor Description LRU()Create a new LRU with 1000 entries.LRU(int max)Create a new LRU.LRU(int max, ILRUEntryCleaner cleaner)Create a new LRU.LRU(int max, ILRUEntryCleaner cleaner, boolean accessorder)Create a new LRU. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ILRUEntryCleanergetCleaner()Get the cleaner object.intgetMaxEntries()Get the maximum number of theVput(K key, V value)booleanremoveEldestEntry(java.util.Map.Entry<K,V> eldest)Remove the eldest entry.voidsetCleaner(ILRUEntryCleaner cleaner)Set the cleaner object.voidsetMaxEntries(int max)Set the maximum number of entries.- 
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, putAll, putIfAbsent, remove, remove, replace, replace, size 
 - 
 
 - 
 
- 
- 
Field Detail
- 
max
protected int max
The maximum number of entries. 
- 
cleaner
protected ILRUEntryCleaner cleaner
The entry cleaner (for performing cleanup code on removed entries). 
 - 
 
- 
Constructor Detail
- 
LRU
public LRU()
Create a new LRU with 1000 entries. 
- 
LRU
public LRU(int max)
Create a new LRU.- Parameters:
 max- The maximum number of entries.
 
- 
LRU
public LRU(int max, ILRUEntryCleaner cleaner)Create a new LRU.- Parameters:
 max- The maximum number of entries.
 
- 
LRU
public LRU(int max, ILRUEntryCleaner cleaner, boolean accessorder)Create a new LRU.- Parameters:
 max- The maximum number of entries.cleaner- Optional cleaner.accessorder- If true, entry use is refreshed on read as well as write.
 
 - 
 
- 
Method Detail
- 
getMaxEntries
public int getMaxEntries()
Get the maximum number of the- Returns:
 - The maximum number of entries.
 
 
- 
setMaxEntries
public void setMaxEntries(int max)
Set the maximum number of entries.- Parameters:
 max- The maximum number of entries.
 
- 
getCleaner
public ILRUEntryCleaner getCleaner()
Get the cleaner object.- Returns:
 - The cleaner object.
 
 
- 
setCleaner
public void setCleaner(ILRUEntryCleaner cleaner)
Set the cleaner object.- Parameters:
 cleaner- The cleaner object.
 
 - 
 
 -