org.objectweb.jonathan.libs.helpers

Class 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

Object
get(Object key)
Returns the element identified by key, or null if none exists, or if it has been registered using this put method.
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.
int
getInt(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.
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.
static HTable
newTable()
Returns a new HTable, taken from a pool of tables.
Object
put(Object key, Object value)
Adds a new element to the target table.
int
put(Object key, int value)
Adds a new element to the target table.
Object
put(int key, Object value)
Adds a new element to the target table.
int
put(int key, int value)
Adds a new element to the target table.
void
release()
Releases the target table.
void
remove(Object key)
Removes the element identified by the provided key from the table.
void
remove(int key)
Removes the element identified by the provided key from the table.
void
reset()
Removes all the elements from the target table.

Method Details

get

public Object get(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 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(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.


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.


put

public Object put(Object key,
                  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 int put(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 Object put(int key,
                  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(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.


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.


remove

public void remove(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.


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.