org.rakeshv.utils
Class LRU<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
org.rakeshv.utils.LinkedHashMap<K,V>
org.rakeshv.utils.LRU<K,V>
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.util.Map<K,V>
class LRU<K,V>
- extends LinkedHashMap<K,V>
A Least Recently Used implementation
using a LinkedHashMap.
Note: This class uses the LinkedHashMap introducted in
the Java 1.4 version, and replaces the old implementation that has
been renamed as SimpleLRU.
Copyright 2004-2006 Rakesh Vidyadharan
- Version:
- $Id: LRU.java,v 1.9 2006/03/11 04:15:14 rakesh Exp $
- Author:
- Rakesh Vidyadharan 2004 May 2
| Nested classes/interfaces inherited from interface java.util.Map |
java.util.Map.Entry<K,V> |
|
Constructor Summary |
LRU()
Default constructor. |
LRU(int capacity)
Constructs an empty access-ordered instance with the specified
initial capacity and a default load factor of LinkedHashMap.DEFAULT_LOAD_FACTOR. |
LRU(int capacity,
float loadFactor)
Constructs an empty access-ordered instance with the specified
initial capacity and load factor. |
LRU(java.util.Map<K,V> map)
Constructs an access-ordered LRU instance with the same
mappings as the specified map. |
| Methods inherited from class java.util.LinkedHashMap |
containsValue |
| Methods inherited from class java.util.HashMap |
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values |
| 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 |
containsKey, containsValue, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
LRU
LRU()
- Default constructor. Creates a new Map with
LinkedHashMap.DEFAULT_CAPACITY capacity and a load factor of LinkedHashMap.DEFAULT_LOAD_FACTOR. If this form of the constructor is used,
then the cache size will not be controlled.
- See Also:
LRU( int, float )
LRU
LRU(int capacity)
- Constructs an empty access-ordered instance with the specified
initial capacity and a default load factor of
LinkedHashMap.DEFAULT_LOAD_FACTOR.
- Parameters:
capacity - The maximum size for this map.- See Also:
LRU( int, float )
LRU
LRU(int capacity,
float loadFactor)
- Constructs an empty access-ordered instance with the specified
initial capacity and load factor. This is the designated
constructor that is used by all other constructors.
- Parameters:
capacity - The maximum size for this map.loadFactor - The load-factor to use.
LRU
LRU(java.util.Map<K,V> map)
- Constructs an access-ordered LRU instance with the same
mappings as the specified map. The LRU instance is
created with a a default load factor of
LinkedHashMap.DEFAULT_LOAD_FACTOR and a capacity sufficient to hold the
mappings in the specified map.
- Parameters:
map - The map to use to create the new instance.
- Throws:
java.lang.NullPointerException - If the specified map is null.- See Also:
LRU( int )
Copyright © 2002-2005 - Rakesh Vidyadharan