net.spy.util
Class TimeStampedHashMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by net.spy.util.TimeStampedHashMap<K,V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<K,V>

public class TimeStampedHashMap<K,V>
extends java.util.HashMap<K,V>

A HashMap that remembers when it was accessed. Good for caching and stuff like that.

See Also:
Serialized Form

Constructor Summary
TimeStampedHashMap()
          Get an instance of TimeStampedHashMap.
 
Method Summary
 V get(java.lang.Object key)
          Get an object from the map.
 long getGetAge()
          How many milliseconds ago was the last get operation?
 long getHits()
          Get the number of hits (number of requests for items that were actually there).
 long getLastGet()
          Find out the last time this thing last had a Get.
 long getLastPut()
          Find out the last time this thing last had a Put.
 long getMisses()
          Get the number of misses (number of requests for items that were not actually there).
 long getNumPuts()
          Get the total number of put() invocations.
 long getPutAge()
          How many milliseconds ago was the last put operation?
 long getTimestamp()
          Find out the last time this thing was used (put or get was called).
 long getUseAge()
          How many milliseconds ago was the last put or get operation?
 long getWatermark()
          Get the watermark (maximum number of objects seen at any one time).
 V put(K key, V value)
          Put an object into the map.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, 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
equals, hashCode
 

Constructor Detail

TimeStampedHashMap

public TimeStampedHashMap()
Get an instance of TimeStampedHashMap.

Method Detail

get

public V get(java.lang.Object key)
Get an object from the map.

Specified by:
get in interface java.util.Map<K,V>
Overrides:
get in class java.util.HashMap<K,V>
Parameters:
key - the object to get
Returns:
the object, or null if it's missing

put

public V put(K key,
             V value)
Put an object into the map.

Specified by:
put in interface java.util.Map<K,V>
Overrides:
put in class java.util.HashMap<K,V>
Parameters:
key - the key to store
value - the value to store
Returns:
the object that got displaced for this store, or null

getTimestamp

public long getTimestamp()
Find out the last time this thing was used (put or get was called).


getLastGet

public long getLastGet()
Find out the last time this thing last had a Get.


getLastPut

public long getLastPut()
Find out the last time this thing last had a Put.


getPutAge

public long getPutAge()
How many milliseconds ago was the last put operation?


getGetAge

public long getGetAge()
How many milliseconds ago was the last get operation?


getUseAge

public long getUseAge()
How many milliseconds ago was the last put or get operation?


getHits

public long getHits()
Get the number of hits (number of requests for items that were actually there).


getMisses

public long getMisses()
Get the number of misses (number of requests for items that were not actually there).


getWatermark

public long getWatermark()
Get the watermark (maximum number of objects seen at any one time).


getNumPuts

public long getNumPuts()
Get the total number of put() invocations.



Copyright © 1995-2007 SPY Internetworking. All Rights Reserved.