org.apache.camel.util
Class LRUCache<K,V>

java.lang.Object
  extended by org.apache.camel.util.LRUCache<K,V>
All Implemented Interfaces:
Serializable, Map<K,V>
Direct Known Subclasses:
LRUSoftCache

public class LRUCache<K,V>
extends Object
implements Map<K,V>, Serializable

A Least Recently Used Cache

Version:
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
LRUCache(int maximumCacheSize)
           
LRUCache(int initialCapacity, int maximumCacheSize)
          Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize,load factor and ordering mode.
 
Method Summary
 void clear()
           
 boolean containsKey(Object o)
           
 boolean containsValue(Object o)
           
 Set<Map.Entry<K,V>> entrySet()
           
 V get(Object o)
           
 long getHits()
          Gets the number of cache hits
 int getMaxCacheSize()
          Returns the maxCacheSize.
 long getMisses()
          Gets the number of cache misses.
 boolean isEmpty()
           
 Set<K> keySet()
           
 V put(K k, V v)
           
 void putAll(Map<? extends K,? extends V> map)
           
 V remove(Object o)
           
 void resetStatistics()
          Rest the cache statistics such as hits and misses.
 int size()
           
 String toString()
           
 Collection<V> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

LRUCache

public LRUCache(int maximumCacheSize)

LRUCache

public LRUCache(int initialCapacity,
                int maximumCacheSize)
Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize,load factor and ordering mode.

Parameters:
initialCapacity - the initial capacity.
maximumCacheSize - the max capacity.
Throws:
IllegalArgumentException - if the initial capacity is negative or the load factor is non positive.
Method Detail

get

public V get(Object o)
Specified by:
get in interface Map<K,V>

size

public int size()
Specified by:
size in interface Map<K,V>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<K,V>

containsKey

public boolean containsKey(Object o)
Specified by:
containsKey in interface Map<K,V>

containsValue

public boolean containsValue(Object o)
Specified by:
containsValue in interface Map<K,V>

put

public V put(K k,
             V v)
Specified by:
put in interface Map<K,V>

remove

public V remove(Object o)
Specified by:
remove in interface Map<K,V>

putAll

public void putAll(Map<? extends K,? extends V> map)
Specified by:
putAll in interface Map<K,V>

clear

public void clear()
Specified by:
clear in interface Map<K,V>

keySet

public Set<K> keySet()
Specified by:
keySet in interface Map<K,V>

values

public Collection<V> values()
Specified by:
values in interface Map<K,V>

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K,V>

getHits

public long getHits()
Gets the number of cache hits


getMisses

public long getMisses()
Gets the number of cache misses.


getMaxCacheSize

public int getMaxCacheSize()
Returns the maxCacheSize.


resetStatistics

public void resetStatistics()
Rest the cache statistics such as hits and misses.


toString

public String toString()
Overrides:
toString in class Object


Apache CAMEL