org.egothor.util
Class Cache<K,V>

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

public class Cache<K,V>
extends java.util.LinkedHashMap<K,V>

This class IS synchronized.

Author:
Leo Galambos
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
 int capacity
          Maximum capacity of this object.
 
Constructor Summary
Cache(int capacity)
          Constructor for the Cache object
 
Method Summary
 void clear()
          Description of the Method
 boolean containsKey(java.lang.Object key)
          Description of the Method
 V get(java.lang.Object key)
          Description of the Method
 float missRate()
          Description of the Method
 V put(K key, V value)
          Description of the Method
 V remove(java.lang.Object key)
          Description of the Method
protected  boolean removeEldestEntry(java.util.Map.Entry<K,V> value)
          Description of the Method
 int size()
          Description of the Method
 
Methods inherited from class java.util.LinkedHashMap
containsValue
 
Methods inherited from class java.util.HashMap
clone, entrySet, isEmpty, keySet, putAll, 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
entrySet, equals, hashCode, isEmpty, keySet, putAll, values
 

Field Detail

capacity

public int capacity
Maximum capacity of this object.

Constructor Detail

Cache

public Cache(int capacity)
Constructor for the Cache object

Parameters:
capacity - Description of the Parameter
Method Detail

get

public V get(java.lang.Object key)
Description of the Method

Specified by:
get in interface java.util.Map<K,V>
Overrides:
get in class java.util.LinkedHashMap<K,V>
Parameters:
key - Description of the Parameter
Returns:
Description of the Return Value

size

public int size()
Description of the Method

Specified by:
size in interface java.util.Map<K,V>
Overrides:
size in class java.util.HashMap<K,V>
Returns:
Description of the Return Value

containsKey

public boolean containsKey(java.lang.Object key)
Description of the Method

Specified by:
containsKey in interface java.util.Map<K,V>
Overrides:
containsKey in class java.util.HashMap<K,V>
Parameters:
key - Description of the Parameter
Returns:
Description of the Return Value

remove

public V remove(java.lang.Object key)
Description of the Method

Specified by:
remove in interface java.util.Map<K,V>
Overrides:
remove in class java.util.HashMap<K,V>
Parameters:
key - Description of the Parameter
Returns:
Description of the Return Value

put

public V put(K key,
             V value)
Description of the Method

Specified by:
put in interface java.util.Map<K,V>
Overrides:
put in class java.util.HashMap<K,V>
Parameters:
key - Description of the Parameter
value - Description of the Parameter
Returns:
Description of the Return Value

missRate

public float missRate()
Description of the Method

Returns:
Description of the Return Value

clear

public void clear()
Description of the Method

Specified by:
clear in interface java.util.Map<K,V>
Overrides:
clear in class java.util.LinkedHashMap<K,V>

removeEldestEntry

protected boolean removeEldestEntry(java.util.Map.Entry<K,V> value)
Description of the Method

Overrides:
removeEldestEntry in class java.util.LinkedHashMap<K,V>
Parameters:
value - Description of the Parameter
Returns:
Description of the Return Value