org.objectweb.jonathan.libs.helpers
Class HTable

java.lang.Object
  extended by org.objectweb.jonathan.libs.helpers.HTable

public final class HTable
extends java.lang.Object

Implements a hash table with integer or object keys and values. Instance methods on HTable are NOT SYNCHRONIZED. It is up to the user to take the appropriate locks when necessary.


Method Summary
 java.lang.Object get(int key)
          Returns the element identified by key, or null if none exists, or if it has been registered using this put method.
 java.lang.Object get(java.lang.Object key)
          Returns the element identified by key, or null if none exists, or if it has been registered using this put method.
 int getInt(int key)
          Returns the element identified by key, or Integer.MAX_VALUE if none exists, or if it has been registered using this put method.
 int getInt(java.lang.Object key)
          Returns the element identified by key, or Integer.MAX_VALUE if none exists, or if it has been registered using this put method.
static HTable newTable()
          Returns a new HTable, taken from a pool of tables.
 int put(int key, int value)
          Adds a new element to the target table.
 java.lang.Object put(int key, java.lang.Object value)
          Adds a new element to the target table.
 int put(java.lang.Object key, int value)
          Adds a new element to the target table.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Adds a new element to the target table.
 void release()
          Releases the target table.
 void remove(int key)
          Removes the element identified by the provided key from the table.
 void remove(java.lang.Object key)
          Removes the element identified by the provided key from the table.
 void reset()
          Removes all the elements from the target table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Adds a new element to the target table.

This method is NOT synchronized: users need to manage the appropriate monitors if necessary.

Parameters:
key - a (non-null) key to identify the element;
value - the (non-null) value of the element;
Returns:
the previous value, if any, otherwise null.

put

public java.lang.Object put(int key,
                            java.lang.Object value)
Adds a new element to the target table.

This method is NOT synchronized: users need to manage the appropriate monitors if necessary.

Parameters:
key - a key to identify the element;
value - the (non-null) value of the element;
Returns:
the previous value, if any, otherwise null.

put

public int put(java.lang.Object key,
               int value)
Adds a new element to the target table.

This method is NOT synchronized: users need to manage the appropriate monitors if necessary.

Parameters:
key - a (non-null) key to identify the element;
value - the value of the element;
Returns:
the previous value, if any, otherwise Integer.MAX_VALUE.

put

public int put(int key,
               int value)
Adds a new element to the target table.

This method is NOT synchronized: users need to manage the appropriate monitors if necessary.

Parameters:
key - a key to identify the element;
value - the value of the element;
Returns:
the previous value, if any, otherwise Integer.MAX_VALUE.

remove

public void remove(java.lang.Object key)
Removes the element identified by the provided key from the table.

This method is NOT synchronized: users need to manage the appropriate monitors if necessary.

Parameters:
key - the element identifier.

remove

public void remove(int key)
Removes the element identified by the provided key from the table.

This method is NOT synchronized: users need to manage the appropriate monitors if necessary.

Parameters:
key - the element identifier.

get

public java.lang.Object get(java.lang.Object key)
Returns the element identified by key, or null if none exists, or if it has been registered using this put method.

This method is NOT synchronized: users need to manage the appropriate monitors if necessary.

Parameters:
key - an element identifier.
Returns:
the corresponding element.

get

public java.lang.Object get(int key)
Returns the element identified by key, or null if none exists, or if it has been registered using this put method.

This method is NOT synchronized: users need to manage the appropriate monitors if necessary.

Parameters:
key - an element identifier.
Returns:
the corresponding element.

getInt

public int getInt(java.lang.Object key)
Returns the element identified by key, or Integer.MAX_VALUE if none exists, or if it has been registered using this put method.

This method is NOT synchronized: users need to manage the appropriate monitors if necessary.

Parameters:
key - an element identifier.
Returns:
the corresponding element.

getInt

public int getInt(int key)
Returns the element identified by key, or Integer.MAX_VALUE if none exists, or if it has been registered using this put method.

This method is NOT synchronized: users need to manage the appropriate monitors if necessary.

Parameters:
key - an element identifier.
Returns:
the corresponding element.

release

public void release()
Releases the target table. The table should no longer be used afterwards.

This method is NOT synchronized: users need to manage the appropriate monitors if necessary.


reset

public void reset()
Removes all the elements from the target table.

This method is NOT synchronized: users need to manage the appropriate monitors if necessary.


newTable

public static HTable newTable()
Returns a new HTable, taken from a pool of tables.

Returns:
a new HTable, taken from a pool of tables.