An implementation of a Map which has a maximum size and uses a Least Recently Used algorithm to remove items from the Map when the maximum size is reached and new items are added.
A synchronized version can be obtained with: Collections.synchronizedMap( theMapToSynchronize )
If it will be accessed by multiple threads, you _must_ synchronize access to this Map. Even concurrent get(Object) operations produce indeterminate behaviour.
Unlike the Collections 1.0 version, this version of LRUMap does use a true LRU algorithm. The keys for all gets and puts are moved to the front of the list. LRUMap is now a subclass of SequencedHashMap, and the "LRU" key is now equivalent to LRUMap.getFirst().
@since Commons Collections 1.0 @version $Revision: 1.2 $ $Date: 2004/02/25 14:02:31 $ @author James Strachan @author Morgan DelagrangeAn implementation of a Map which has a maximum size and uses a Least Recently Used algorithm to remove items from the Map when the maximum size is reached and new items are added.
This implementation uses a simple bubbling algorithm, whereby every random access get() method call bubbles the item up the list, further away from the 'drop zone'.
A synchronized version can be obtained with: Collections.synchronizedMap( theMapToSynchronize )
WARNING the values() and entrySet() methods require optimisation like the standard {@link HashMap} implementations so that iterationover this Map is efficient.
@author James StrachanMap
implementation with a fixed maximum size which removes the least recently used entry if an entry is added when full. The least recently used algorithm works on the get and put operations only. Iteration of any kind, including setting the value by iteration, does not change the order. Queries such as containsKey and containsValue or access via views also do not change the order.
The map implements OrderedMap
and entries may be queried using the bidirectional OrderedMapIterator
. The order returned is least recently used to most recently used. Iterators from map views can also be cast to OrderedIterator
if required.
All the available iterators can be reset back to the start by casting to ResettableIterator
and calling reset()
.
@since Commons Collections 3.0 (previously in main package v1.0)
@version $Revision: 1.14 $ $Date: 2004/06/07 22:13:53 $
@author James Strachan
@author Morgan Delagrange
@author Stephen Colebourne
@author Mike Pettypiece
@author Mario Ivankovits
Children can implement the processRemovedLRU method if they want to handle the removal of the lest recently used item.
This class was abstracted out of the LRU Memory cache. Put, remove, and get should be thread safe. It uses a hashtable and our own double linked list.
Locking is done on the instance.
@author aaronsm
LRUMap
that can change its maximum size.
@author Abe White
@nojavadoc
Map
interface. Instances are not thread-safe and should be synchronized externally, for instance by using {@link java.util.Collections#synchronizedMap}.
@author Manuel Dominguez Sarmiento
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|