org.owasp.webscarab.util
Class MRUCache

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap
              extended by org.owasp.webscarab.util.MRUCache
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map

public class MRUCache
extends java.util.LinkedHashMap

maintains a Most-Recently-Used cache of its entries, up to the max size specified

Author:
knoppix
See Also:
Serialized Form

Constructor Summary
MRUCache(int maxSize)
          Creates a new instance of MRUCache, with an initial size of 16, and a load factor of 0.75
MRUCache(int initialCapacity, int maxSize)
          Creates a new instance of MRUCache, with a load factor of 0.75
MRUCache(int initialCapacity, int maxSize, float loadFactor)
          Creates a new instance of MRUCache
 
Method Summary
protected  boolean removeEldestEntry(java.util.Map.Entry eldest)
          called to determine whether the eldest entry should be removed.
 
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, get
 
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, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

MRUCache

public MRUCache(int maxSize)
Creates a new instance of MRUCache, with an initial size of 16, and a load factor of 0.75

Parameters:
maxSize - the maximum size of the cache

MRUCache

public MRUCache(int initialCapacity,
                int maxSize)
Creates a new instance of MRUCache, with a load factor of 0.75

Parameters:
initialCapacity - the preferred initial capacity
maxSize - the maximum size of the cache

MRUCache

public MRUCache(int initialCapacity,
                int maxSize,
                float loadFactor)
Creates a new instance of MRUCache

Parameters:
loadFactor - the preferred load factor
initialCapacity - the preferred initial capacity
maxSize - the maximum size of the cache
Method Detail

removeEldestEntry

protected boolean removeEldestEntry(java.util.Map.Entry eldest)
called to determine whether the eldest entry should be removed. Eldest is defined in terms of access order, so a more recently used entry will stay "young"

Overrides:
removeEldestEntry in class java.util.LinkedHashMap
Parameters:
eldest - the entry
Returns:
true if this entry should be removed, false otherwise