classUtils.pack.util
Class Cache

java.lang.Object
  extended by classUtils.pack.util.Cache

public class Cache
extends java.lang.Object

A simple cache object, which holds affineTransform most n references.

Author:
Cristiano Sadun

Constructor Summary
Cache(int max)
          Constructor for Cache.
 
Method Summary
 java.lang.Object get(java.lang.Object key)
          Find an object into the cache.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Put an object in the cache.
 java.lang.Object remove(java.lang.Object key)
          Remove an object from the cache.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cache

public Cache(int max)
Constructor for Cache.

Parameters:
max - the maximum number of references to hold.
Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Put an object in the cache. If the cache size exceed the maximum size, the least accessed object will be removed.

Parameters:
key - of the object to put.
Returns:
the object just inserted.

remove

public java.lang.Object remove(java.lang.Object key)
Remove an object from the cache.

Parameters:
key - of the object to remove.
Returns:
null or the object corresponding to the key.

get

public java.lang.Object get(java.lang.Object key)
Find an object into the cache.

Parameters:
key - the key of the object to get.
Returns:
null or the object corresponding to the key.