| java.lang.Object org.openlaszlo.utils.HashIntTable
HashIntTable | final public class HashIntTable (Code) | | This class provides unsynchronized hash get, put, remove
and increment of int values. If multiple threads are accessing
the table then access to the table must be synchronized.
author: Riad Mohammed |
Field Summary | |
Entry[] | table |
Constructor Summary | |
public | HashIntTable() | public | HashIntTable(int size, int defaultValue) Create the HashIntTable with the specified
size. |
Method Summary | |
public boolean | containsKey(Object key) Check if key exists
Parameters: key - the key. | public int | get(Object key) Get the value of the specified key. | public int | increment(Object key, int increment) Increment the value associated with the specified key
by the specified amount.
If key does not exist in the table then increment the
default value and store the result
Parameters: key - the key. | public Enumeration | keys() Return the enumeration of keys. | public static void | main(String args) | public int | put(Object key, int value) Associate the specified key with the
specified value.
Parameters: key - the key. | public int | remove(Object key) Remove the value for specified key
Parameters: key - the key. | public int | size() Return the size of the HashIntTable. |
table | Entry[] table(Code) | | The array of entries
|
HashIntTable | public HashIntTable()(Code) | | Create the HashIntTable using the default
size
|
HashIntTable | public HashIntTable(int size, int defaultValue)(Code) | | Create the HashIntTable with the specified
size.
Parameters: size - the size (must be greater than zero) |
containsKey | public boolean containsKey(Object key)(Code) | | Check if key exists
Parameters: key - the key. Cannot be null. the value of the key in the table |
get | public int get(Object key)(Code) | | Get the value of the specified key. If the key does not
exist in the table return the default value.
Parameters: key - the key. Cannot be null. the value of the key in the table |
increment | public int increment(Object key, int increment)(Code) | | Increment the value associated with the specified key
by the specified amount.
If key does not exist in the table then increment the
default value and store the result
Parameters: key - the key. Cannot be null Parameters: increment - the increment the incremented value |
keys | public Enumeration keys()(Code) | | Return the enumeration of keys.
If the size of the HashIntTable changes
(via put, remove, increment) while the
keys are being enuemrated a
ConcurrentModificationException is thrown
by the enumeration.
the enumeration of keys. |
put | public int put(Object key, int value)(Code) | | Associate the specified key with the
specified value.
Parameters: key - the key. Cannot be null Parameters: value - the new value the existing value. If thekey does not exist in the tablereturn the default value. |
remove | public int remove(Object key)(Code) | | Remove the value for specified key
Parameters: key - the key. Cannot be null. the old value. If the key does not exist in thetable return the default value. |
size | public int size()(Code) | | Return the size of the HashIntTable.
the size of the HashIntTable. |
|
|