gnu.trove
public abstract class THash extends Object implements Cloneable
Version: $Id: THash.java,v 1.6 2002/09/25 05:43:04 ericdf Exp $
| Field Summary | |
|---|---|
| protected static int | DEFAULT_INITIAL_CAPACITY the default initial capacity for the hash table. |
| protected static float | DEFAULT_LOAD_FACTOR the load above which rehashing occurs. |
| protected int | _free the current number of free slots in the hash. |
| protected float | _loadFactor Determines how full the internal table can become before
rehashing is required. |
| protected int | _maxSize
The maximum number of elements allowed without allocating more
space. |
| protected int | _size the current number of occupied slots in the hash. |
| Constructor Summary | |
|---|---|
| THash()
Creates a new THash instance with the default
capacity and load factor. | |
| THash(int initialCapacity)
Creates a new THash instance with a prime capacity
at or near the specified capacity and with the default load
factor.
| |
| THash(int initialCapacity, float loadFactor)
Creates a new THash instance with a prime capacity
at or near the minimum needed to hold initialCapacity
elements with load factor loadFactor without triggering
a rehash.
| |
| Method Summary | |
|---|---|
| protected abstract int | capacity() |
| void | clear()
Empties the collection. |
| Object | clone() |
| void | compact()
Compresses the hashtable to the minimum prime size (as defined
by PrimeFinder) that will hold all of the elements currently in
the table. |
| void | computeMaxSize(int capacity)
Computes the values of maxSize. |
| void | ensureCapacity(int desiredCapacity)
Ensure that this hashtable has sufficient capacity to hold
desiredCapacity additional elements without
requiring a rehash. |
| boolean | isEmpty()
Tells whether this set is currently holding any elements.
|
| protected void | postInsertHook(boolean usedFreeSlot)
After an insert, this hook is called to adjust the size/free
values of the set and to perform rehashing if necessary. |
| protected abstract void | rehash(int newCapacity)
Rehashes the set.
|
| protected void | removeAt(int index)
Delete the record at index. |
| protected int | setUp(int initialCapacity)
initializes the hashtable to a prime capacity which is at least
initialCapacity + 1.
|
| int | size()
Returns the number of distinct elements in this collection.
|
| void | trimToSize()
This simply calls compact. |
THash instance with the default
capacity and load factor.THash instance with a prime capacity
at or near the specified capacity and with the default load
factor.
Parameters: initialCapacity an int value
THash instance with a prime capacity
at or near the minimum needed to hold initialCapacity
elements with load factor loadFactor without triggering
a rehash.
Parameters: initialCapacity an int value loadFactor a float value
Returns: the current physical capacity of the hash table.
Parameters: capacity an int value
Parameters: desiredCapacity an int value
Returns: a boolean value
Parameters: newCapacity an int value
Parameters: index an int value
Parameters: initialCapacity an int value
Returns: the actual capacity chosen
Returns: an int value