All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Acme.LruHashtable

java.lang.Object
   |
   +----java.util.Dictionary
           |
           +----java.util.Hashtable
                   |
                   +----Acme.LruHashtable

public class LruHashtable
extends Hashtable
A Hashtable that expires least-recently-used objects.

Use just like java.util.Hashtable, except that the initial-capacity parameter is required. Instead of growing bigger than that size, it will throw out objects that haven't been looked at in a while.

Fetch the software.
Fetch the entire Acme package.

See Also:
Hashtable

Constructor Index

 o LruHashtable(int)
Constructs a new, empty hashtable with the specified initial capacity.
 o LruHashtable(int, float)
Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.

Method Index

 o clear()
Clears the hash table so that it has no more elements in it.
 o clone()
Creates a clone of the hashtable.
 o contains(Object)
Returns true if the specified object is an element of the hashtable.
 o containsKey(Object)
Returns true if the collection contains an element for the key.
 o elements()
Returns an enumeration of the elements.
 o get(Object)
Gets the object associated with the specified key in the hashtable.
 o isEmpty()
Returns true if the hashtable contains no elements.
 o keys()
Returns an enumeration of the hashtable's keys.
 o put(Object, Object)
Puts the specified element into the hashtable, using the specified key.
 o remove(Object)
Removes the element corresponding to the key.
 o size()
Returns the number of elements contained in the hashtable.

Constructors

 o LruHashtable
 public LruHashtable(int initialCapacity,
                     float loadFactor)
Constructs a new, empty hashtable with the specified initial capacity and the specified load factor. Unlike a plain Hashtable, an LruHashtable will never grow or shrink from this initial capacity.

Parameters:
initialCapacity - the initial number of buckets
loadFactor - a number between 0.0 and 1.0, it defines the threshold for expiring old entries
Throws: IllegalArgumentException
If the initial capacity is less than or equal to zero.
Throws: IllegalArgumentException
If the load factor is less than or equal to zero.
 o LruHashtable
 public LruHashtable(int initialCapacity)
Constructs a new, empty hashtable with the specified initial capacity. Unlike a plain Hashtable, an LruHashtable will never grow or shrink from this initial capacity.

Parameters:
initialCapacity - the initial number of buckets

Methods

 o size
 public int size()
Returns the number of elements contained in the hashtable.

Overrides:
size in class Hashtable
 o isEmpty
 public boolean isEmpty()
Returns true if the hashtable contains no elements.

Overrides:
isEmpty in class Hashtable
 o keys
 public synchronized Enumeration keys()
Returns an enumeration of the hashtable's keys.

Overrides:
keys in class Hashtable
See Also:
elements, Enumeration
 o elements
 public synchronized Enumeration elements()
Returns an enumeration of the elements. Use the Enumeration methods on the returned object to fetch the elements sequentially.

Overrides:
elements in class Hashtable
See Also:
keys, Enumeration
 o contains
 public synchronized boolean contains(Object value)
Returns true if the specified object is an element of the hashtable. This operation is more expensive than the containsKey() method.

Parameters:
value - the value that we are looking for
Throws: NullPointerException
If the value being searched for is equal to null.
Overrides:
contains in class Hashtable
See Also:
containsKey
 o containsKey
 public synchronized boolean containsKey(Object key)
Returns true if the collection contains an element for the key.

Parameters:
key - the key that we are looking for
Overrides:
containsKey in class Hashtable
See Also:
contains
 o get
 public synchronized Object get(Object key)
Gets the object associated with the specified key in the hashtable.

Parameters:
key - the specified key
Returns:
s the element for the key or null if the key is not defined in the hash table.
Overrides:
get in class Hashtable
See Also:
put
 o put
 public synchronized Object put(Object key,
                                Object value)
Puts the specified element into the hashtable, using the specified key. The element may be retrieved by doing a get() with the same key. The key and the element cannot be null.

Parameters:
key - the specified key in the hashtable
value - the specified element
Returns:
the old value of the key, or null if it did not have one.
Throws: NullPointerException
If the value of the element is equal to null.
Overrides:
put in class Hashtable
See Also:
get
 o remove
 public synchronized Object remove(Object key)
Removes the element corresponding to the key. Does nothing if the key is not present.

Parameters:
key - the key that needs to be removed
Returns:
the value of key, or null if the key was not found.
Overrides:
remove in class Hashtable
 o clear
 public synchronized void clear()
Clears the hash table so that it has no more elements in it.

Overrides:
clear in class Hashtable
 o clone
 public synchronized Object clone()
Creates a clone of the hashtable. A shallow copy is made, the keys and elements themselves are NOT cloned. This is a relatively expensive operation.

Overrides:
clone in class Hashtable

All Packages  Class Hierarchy  This Package  Previous  Next  Index

ACME Java  ACME Labs