public abstract class TObjectHash<T> extends THashimplements TObjectHashingStrategy <T>
| Modifier and Type | Field and Description |
|---|---|
protected TObjectHashingStrategy |
_hashingStrategy
the strategy used to hash objects in this collection.
|
protected Object |
_set
the set of Objects
|
protected static Object |
FREE
|
protected static Object |
REMOVED
|
_autoCompactionFactor, _autoCompactRemovesRemaining, _free, _loadFactor, _maxSize, _size, DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR| Constructor and Description |
|---|
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
Creates a new
TObjectHash instance with a prime value at or near the specified capacity and load factor.
|
TObjectHash(int initialCapacity, TObjectHashingStrategy
Creates a new
TObjectHash instance whose capacity is the next highest prime above
initialCapacity + 1 unless that value is already prime.
|
TObjectHash(TObjectHashingStrategy
Creates a new
TObjectHash instance with the default capacity and load factor and a custom hashing strategy.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
capacity()
|
TObjectHash |
clone()
|
int |
computeHashCode(T o)
This is the default implementation of TObjectHashingStrategy: it delegates hashing to the Object's hashCode method.
|
boolean |
contains(Object
Searches the set for
obj
|
boolean |
equals(T o1, T o2)
This is the default implementation of TObjectHashingStrategy: it delegates equality comparisons to the first parameter's equals() method.
|
boolean |
forEach(TObjectProcedure
Executes
procedure for each element in the set.
|
protected int |
index(T obj)
Locates the index of
obj.
|
protected int |
insertionIndex(T obj)
Locates the index at which
obj can be inserted.
|
void |
readExternal(ObjectInput
|
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(Object
Convenience methods for subclasses to use in throwing exceptions about badly behaved user objects employed as keys.
|
void |
writeExternal(ObjectOutput
|
calculateGrownCapacity, clear, compact, ensureCapacity, getAutoCompactionFactor, isEmpty, postInsertHook, reenableAutoCompaction, rehash, setAutoCompactionFactor, size, tempDisableAutoCompaction, trimToSizeprotected transient Object[] _set
protected TObjectHashingStrategy<T> _hashingStrategy
protected static final ObjectREMOVED
protected static final ObjectFREE
public TObjectHash()
TObjectHash instance with the default capacity and load factor.
public TObjectHash(TObjectHashingStrategy<T> 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<T> 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 value
strategy - 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<T> 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.
public TObjectHash<T> clone()
protected int capacity()
protected void removeAt(int index)
THash
protected int setUp(int initialCapacity)
public boolean forEach(TObjectProcedure<T> procedure)
procedure - a
TObjectProcedure value
public boolean contains(Objectobj)
obj - an
Object value
boolean value
protected int index(T obj)
obj - an
Object value
protected int insertionIndex(T obj)
obj - an
Object value
public final int computeHashCode(T o)
computeHashCode in interface
TObjectHashingStrategy<T>
o - for which the hashcode is to be computed
Object.hashCode()
public final boolean equals(T o1, T o2)
equals in interface
TObjectHashingStrategy<T>
o1 - an
Object value
o2 - an
Object value
Object.equals(Object)
protected final void throwObjectContractViolation(Objecto1, Object o2) throws IllegalArgumentException
o1 - the first of the equal elements with unequal hash codes.
o2 - the second of the equal elements with unequal hash codes.
IllegalArgumentException - the whole point of this method.
public void writeExternal(ObjectOutputout) throws IOException
writeExternal in interface
Externalizable
writeExternal in class
THash
IOException
public void readExternal(ObjectInputin) throws IOException , ClassNotFoundException
readExternal in interface
Externalizable
readExternal in class
THash
IOException
ClassNotFoundException