gnu.trove
public abstract class TObjectHash extends THash implements Serializable, TObjectHashingStrategy
Version: $Id: TObjectHash.java,v 1.15 2003/03/23 04:06:59 ericdf Exp $
| Field Summary | |
|---|---|
| protected static Object | REMOVED |
| protected TObjectHashingStrategy | _hashingStrategy the strategy used to hash objects in this collection. |
| protected Object[] | _set the set of Objects |
| Constructor Summary | |
|---|---|
| TObjectHash()
Creates a new TObjectHash instance with the
default capacity and load factor. | |
| TObjectHash(TObjectHashingStrategy strategy)
Creates a new TObjectHash instance with the
default capacity and load factor and a custom hashing strategy.
| |
| TObjectHash(int initialCapacity)
Creates a new TObjectHash instance whose capacity
is the next highest prime above initialCapacity + 1
unless that value is already prime.
| |
| TObjectHash(int initialCapacity, TObjectHashingStrategy strategy)
Creates a new TObjectHash instance whose capacity
is the next highest prime above initialCapacity + 1
unless that value is already prime. | |
| TObjectHash(int initialCapacity, float loadFactor)
Creates a new TObjectHash instance with a prime
value at or near the specified capacity and load factor.
| |
| TObjectHash(int initialCapacity, float loadFactor, TObjectHashingStrategy strategy)
Creates a new TObjectHash instance with a prime
value at or near the specified capacity and load factor. | |
| Method Summary | |
|---|---|
| protected int | capacity() |
| Object | clone() |
| int | computeHashCode(Object o)
This is the default implementation of TObjectHashingStrategy:
it delegates hashing to the Object's hashCode method.
|
| boolean | contains(Object obj)
Searches the set for obj
|
| boolean | equals(Object o1, Object o2)
This is the default implementation of TObjectHashingStrategy:
it delegates equality comparisons to the first parameter's
equals() method.
|
| boolean | forEach(TObjectProcedure procedure)
Executes procedure for each element in the set.
|
| protected int | index(Object obj)
Locates the index of obj.
|
| protected int | insertionIndex(Object obj)
Locates the index at which obj can be inserted. if
there is already a value equal()ing obj in the set,
returns that value's index as -index - 1.
|
| protected void | removeAt(int index) |
| protected int | setUp(int initialCapacity)
initializes the Object set of this hash table.
|
| protected void | throwObjectContractViolation(Object o1, Object o2)
Convenience methods for subclasses to use in throwing exceptions about
badly behaved user objects employed as keys. |
TObjectHash instance with the
default capacity and load factor.TObjectHash instance with the
default capacity and load factor and a custom hashing strategy.
Parameters: strategy used to compute hash codes and to compare objects.
TObjectHash instance whose capacity
is the next highest prime above initialCapacity + 1
unless that value is already prime.
Parameters: initialCapacity an int value
TObjectHash instance whose capacity
is the next highest prime above initialCapacity + 1
unless that value is already prime. Uses the specified custom
hashing strategy.
Parameters: initialCapacity an int value strategy used to compute hash codes and to compare objects.
TObjectHash instance with a prime
value at or near the specified capacity and load factor.
Parameters: initialCapacity used to find a prime capacity for the table. loadFactor used to calculate the threshold over which rehashing takes place.
TObjectHash instance with a prime
value at or near the specified capacity and load factor. Uses
the specified custom hashing strategy.
Parameters: initialCapacity used to find a prime capacity for the table. loadFactor used to calculate the threshold over which rehashing takes place. strategy used to compute hash codes and to compare objects.
Returns: a shallow clone of this collection
Parameters: object for which the hashcode is to be computed
Returns: the hashCode
See Also: Object#hashCode()
Parameters: obj an Object value
Returns: a boolean value
Parameters: o1 an Object value o2 an Object value
Returns: true if the objects are equal
See Also: Object#equals(Object)
Parameters: procedure a TObjectProcedure value
Returns: false if the loop over the set terminated because the procedure returned false for some value.
Parameters: obj an Object value
Returns: the index of obj or -1 if it isn't in the set.
Parameters: obj an Object value
Returns: the index of a FREE slot at which obj can be inserted or, if obj is already stored in the hash, the negative value of that index, minus 1: -index -1.
Parameters: initialCapacity an int value
Returns: an int value
Parameters: o1 the first of the equal elements with unequal hash codes. o2 the second of the equal elements with unequal hash codes.
Throws: IllegalArgumentException the whole point of this method.