jade.util
Class HashCache

java.lang.Object
  |
  +--jade.util.HashCache

public class HashCache
extends java.lang.Object

This class is a cache with fixed dimension that can be set in the constructur. All element are indexed with an hashcode. When an element is added and the cache is already full,the oldest element is deleted.

Version:
$Date: 2003/01/22 09:47:53 $ $Revision: 1.3 $
Author:
Alessandro Chiarotto, Fabio Bellifemine - TILAB S.p.A.

Constructor Summary
HashCache(int cacheSize)
          Constructs a new, empty HashCache with the specified size.
 
Method Summary
 java.lang.Object add(java.lang.Object o)
          Adds the specified element to this hashcache if it is not already present.
 boolean contains(java.lang.Object o)
          Tests if the specified object is a key in this hashcache. present. the oldest element is deleted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashCache

public HashCache(int cacheSize)
Constructs a new, empty HashCache with the specified size.
Parameters:
cacheSize - is the size of this cache
Method Detail

add

public java.lang.Object add(java.lang.Object o)
Adds the specified element to this hashcache if it is not already present. If the cache is already full,the oldest element is deleted.
Parameters:
o - element to be added to this set.
Returns:
o the specified added object element.

contains

public boolean contains(java.lang.Object o)
Tests if the specified object is a key in this hashcache. present. the oldest element is deleted.
Parameters:
o - element to be added to this set.
Returns:
true if the haschcache contains the object o, otherwise false