com.imagero.util
Class LSPHashtable

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended bycom.imagero.util.LSPHashtable
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class LSPHashtable
extends java.util.Hashtable

LSPHashtable.java LS = LimitedSize P = Priority Objects with low priority removed first if table is full

See Also:
Serialized Form

Nested Class Summary
protected  class LSPHashtable.PObject
           
 
Constructor Summary
LSPHashtable(int maxCapacity, int maxPriority)
          Constructs a new, empty hashtable with a default initial capacity (11)
 
Method Summary
 java.util.Enumeration elements()
          Returns an enumeration of the values in this hashtable.
protected  void finalizeObject(LSPHashtable.PObject o)
           
 java.lang.Object get(java.lang.Object key)
          Returns the value to which the specified key is mapped in this hashtable.
 int getMaxPriority()
          max allowed priority for this LSPHastable
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Maps the specified key to the specified value in this hashtable.
 java.lang.Object put(java.lang.Object key, java.lang.Object value, int p)
          Maps the specified key to the specified value in this hashtable.
 void putAll(java.util.Map t, int p)
          Copies all of the mappings from the specified Map to this Hashtable
 java.lang.Object remove(java.lang.Object key)
          Removes the key (and its corresponding value) from this hashtable.
 void removeAll(int p)
          remove all Objects with priority < p
protected  LSPHashtable.PObject removeP(java.lang.Object key)
           
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, entrySet, equals, hashCode, isEmpty, keys, keySet, putAll, rehash, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LSPHashtable

public LSPHashtable(int maxCapacity,
                    int maxPriority)
Constructs a new, empty hashtable with a default initial capacity (11)

Parameters:
maxCapacity - max number of mappings in this LSPHashtable
maxPriority - max number of used priorities for this LSPHashtable maxPriority=3 means that this LSPHashtable use priorities from 0 till 2
Method Detail

elements

public java.util.Enumeration elements()
Description copied from class: java.util.Hashtable
Returns an enumeration of the values in this hashtable. Use the Enumeration methods on the returned object to fetch the elements sequentially.

Returns:
an enumeration of the values in this hashtable.
See Also:
Enumeration, Hashtable.keys(), Hashtable.values(), Map

finalizeObject

protected void finalizeObject(LSPHashtable.PObject o)

get

public java.lang.Object get(java.lang.Object key)
Description copied from class: java.util.Hashtable
Returns the value to which the specified key is mapped in this hashtable.

Parameters:
key - a key in the hashtable.
Returns:
the value to which the key is mapped in this hashtable; null if the key is not mapped to any value in this hashtable.
See Also:
Hashtable.put(Object, Object)

getMaxPriority

public int getMaxPriority()
max allowed priority for this LSPHastable


put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null.

priority of this mapping is 0

Parameters:
key - the hashtable key.
value - the value.
Returns:
the previous value of the specified key in this hashtable, or null if it did not have one.
See Also:
Object.equals(Object), Hashtable.get(Object)

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value,
                            int p)
Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null.

Parameters:
p - priority of this mapping

putAll

public void putAll(java.util.Map t,
                   int p)
Copies all of the mappings from the specified Map to this Hashtable

Parameters:
p - priority

remove

public java.lang.Object remove(java.lang.Object key)
Description copied from class: java.util.Hashtable
Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable.

Parameters:
key - the key that needs to be removed.
Returns:
the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.

removeAll

public void removeAll(int p)
remove all Objects with priority < p


removeP

protected LSPHashtable.PObject removeP(java.lang.Object key)