This class has been copied from Commons Collections, version 2.1 in order
to eliminate the dependency of dbcp on collections. It has package scope
to prevent its inclusion in the dbcp public API. The class declaration below
should *not* be changed to public.
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: 1.0 author: James Strachan author: Morgan Delagrange |