|
GNU Trove | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--gnu.trove.THash
|
+--gnu.trove.TObjectHash
An open addressed hashing implementation for Object types. Created: Sun Nov 4 08:56:06 2001
| Field Summary | |
protected TObjectHashingStrategy |
_hashingStrategy
the strategy used to hash objects in this collection. |
protected java.lang.Object[] |
_set
the set of Objects |
protected static java.lang.Object |
REMOVED
|
| Fields inherited from class gnu.trove.THash |
_free, _loadFactor, _maxSize, _size, DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR |
| Constructor Summary | |
TObjectHash()
Creates a new TObjectHash instance with the
default capacity and load factor. |
|
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,
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. |
|
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(TObjectHashingStrategy strategy)
Creates a new TObjectHash instance with the
default capacity and load factor and a custom hashing strategy. |
|
| Method Summary | |
protected int |
capacity()
|
java.lang.Object |
clone()
|
int |
computeHashCode(java.lang.Object o)
This is the default implementation of TObjectHashingStrategy: it delegates hashing to the Object's hashCode method. |
boolean |
contains(java.lang.Object obj)
Searches the set for obj |
boolean |
equals(java.lang.Object o1,
java.lang.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(java.lang.Object obj)
Locates the index of obj. |
protected int |
insertionIndex(java.lang.Object obj)
Locates the index at which obj can be inserted. |
protected void |
removeAt(int index)
Delete the record at index. |
protected int |
setUp(int initialCapacity)
initializes the Object set of this hash table. |
protected void |
throwObjectContractViolation(java.lang.Object o1,
java.lang.Object o2)
Convenience methods for subclasses to use in throwing exceptions about badly behaved user objects employed as keys. |
| Methods inherited from class gnu.trove.THash |
clear, compact, ensureCapacity, isEmpty, postInsertHook, rehash, size, trimToSize |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected transient java.lang.Object[] _set
protected TObjectHashingStrategy _hashingStrategy
protected static final java.lang.Object REMOVED
| Constructor Detail |
public TObjectHash()
TObjectHash instance with the
default capacity and load factor.
public TObjectHash(TObjectHashingStrategy strategy)
TObjectHash instance with the
default capacity and load factor and a custom hashing strategy.
strategy - used to compute hash codes and to compare objects.public TObjectHash(int initialCapacity)
TObjectHash instance whose capacity
is the next highest prime above initialCapacity + 1
unless that value is already prime.
initialCapacity - an int value
public TObjectHash(int initialCapacity,
TObjectHashingStrategy strategy)
TObjectHash instance whose capacity
is the next highest prime above initialCapacity + 1
unless that value is already prime. Uses the specified custom
hashing strategy.
initialCapacity - an int valuestrategy - used to compute hash codes and to compare objects.
public TObjectHash(int initialCapacity,
float loadFactor)
TObjectHash instance with a prime
value at or near the specified capacity and load factor.
initialCapacity - used to find a prime capacity for the table.loadFactor - used to calculate the threshold over which
rehashing takes place.
public TObjectHash(int initialCapacity,
float loadFactor,
TObjectHashingStrategy strategy)
TObjectHash instance with a prime
value at or near the specified capacity and load factor. Uses
the specified custom hashing strategy.
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.| Method Detail |
public java.lang.Object clone()
clone in class THashprotected int capacity()
capacity in class THashprotected void removeAt(int index)
THash
removeAt in class THashindex - an int valueprotected int setUp(int initialCapacity)
setUp in class THashinitialCapacity - an int value
int valuepublic boolean forEach(TObjectProcedure procedure)
procedure - a TObjectProcedure value
public boolean contains(java.lang.Object obj)
obj - an Object value
boolean valueprotected int index(java.lang.Object obj)
obj - an Object value
protected int insertionIndex(java.lang.Object obj)
obj - an Object value
public final int computeHashCode(java.lang.Object o)
computeHashCode in interface TObjectHashingStrategyObject.hashCode()
public final boolean equals(java.lang.Object o1,
java.lang.Object o2)
equals in interface TObjectHashingStrategyo1 - an Object valueo2 - an Object value
Object.equals(Object)
protected final void throwObjectContractViolation(java.lang.Object o1,
java.lang.Object o2)
throws java.lang.IllegalArgumentException
o1 - the first of the equal elements with unequal hash codes.o2 - the second of the equal elements with unequal hash codes.
java.lang.IllegalArgumentException - the whole point of this method.
|
GNU Trove | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||