public abstract class TObjectHash<T> extends THash
| Modifier and Type | Field and Description |
|---|---|
java.lang.Object[] |
_set
the set of Objects
|
protected boolean |
consumeFreeSlot
Indicates whether the last insertKey() call used a FREE slot.
|
static java.lang.Object |
FREE |
static java.lang.Object |
REMOVED |
_autoCompactionFactor, _autoCompactRemovesRemaining, _autoCompactTemporaryDisable, _free, _loadFactor, _maxSize, _size, DEFAULT_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. |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.IllegalArgumentException |
buildObjectContractViolation(java.lang.Object o1,
java.lang.Object o2,
java.lang.String extra)
Convenience methods for subclasses to use in throwing exceptions about
badly behaved user objects employed as keys.
|
int |
capacity() |
boolean |
contains(java.lang.Object obj)
Searches the set for obj
|
protected java.lang.String |
dumpExtraInfo(java.lang.Object newVal,
java.lang.Object oldVal,
int currentSize,
int oldSize,
java.lang.Object[] oldKeys) |
protected boolean |
equals(java.lang.Object notnull,
java.lang.Object two) |
boolean |
forEach(TObjectProcedure<? super T> procedure)
Executes procedure for each element in the set.
|
protected int |
hash(java.lang.Object notnull) |
protected int |
index(java.lang.Object obj)
Locates the index of obj.
|
protected int |
insertionIndex(T obj)
Deprecated.
use
insertKey(T) instead |
protected int |
insertKey(T key)
Locates the index at which key can be inserted.
|
protected static java.lang.String |
objectInfo(java.lang.Object o) |
void |
readExternal(java.io.ObjectInput in) |
protected void |
removeAt(int index)
Delete the record at index.
|
protected static java.lang.String |
reportPotentialConcurrentMod(int newSize,
int oldSize) |
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.
|
protected void |
throwObjectContractViolation(java.lang.Object o1,
java.lang.Object o2,
int size,
int oldSize,
java.lang.Object[] oldKeys)
Convenience methods for subclasses to use in throwing exceptions about
badly behaved user objects employed as keys.
|
void |
writeExternal(java.io.ObjectOutput out) |
calculateGrownCapacity, clear, compact, computeMaxSize, computeNextAutoCompactionAmount, ensureCapacity, fastCeil, getAutoCompactionFactor, isEmpty, postInsertHook, reenableAutoCompaction, rehash, saturatedCast, setAutoCompactionFactor, size, tempDisableAutoCompaction, trimToSizepublic transient java.lang.Object[] _set
public static final java.lang.Object REMOVED
public static final java.lang.Object FREE
protected boolean consumeFreeSlot
public TObjectHash()
TObjectHash instance with the
default capacity and load factor.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 valuepublic 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 int capacity()
protected void removeAt(int index)
THashpublic int setUp(int initialCapacity)
public boolean forEach(TObjectProcedure<? super T> procedure)
procedure - a TObjectProcedure valuepublic boolean contains(java.lang.Object obj)
obj - an Object valueboolean valueprotected int index(java.lang.Object obj)
obj - an Object value@Deprecated protected int insertionIndex(T obj)
insertKey(T) insteadobj - protected int insertKey(T key)
Locates the index at which key can be inserted. if there is already a value equal()ing key in the set, returns that value's index as -index - 1.
If a slot is found the value is inserted. When a FREE slot is used the consumeFreeSlot field is set to true. This field should be used in the method invoking insertKey() to pass to postInsertHook()
key - an Object valueprotected 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.protected final void throwObjectContractViolation(java.lang.Object o1,
java.lang.Object o2,
int size,
int oldSize,
java.lang.Object[] oldKeys)
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.size - oldSize - oldKeys - @throws IllegalArgumentException the whole point of this method.java.lang.IllegalArgumentExceptionprotected final java.lang.IllegalArgumentException buildObjectContractViolation(java.lang.Object o1,
java.lang.Object o2,
java.lang.String extra)
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.protected boolean equals(java.lang.Object notnull,
java.lang.Object two)
protected int hash(java.lang.Object notnull)
protected static java.lang.String reportPotentialConcurrentMod(int newSize,
int oldSize)
protected java.lang.String dumpExtraInfo(java.lang.Object newVal,
java.lang.Object oldVal,
int currentSize,
int oldSize,
java.lang.Object[] oldKeys)
newVal - the key being insertedoldVal - the key already stored at that positioncurrentSize - size of the key set during rehashingoldSize - size of the key set before rehashingoldKeys - the old key setprotected static java.lang.String objectInfo(java.lang.Object o)
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.ExternalizablewriteExternal in class THashjava.io.IOExceptionpublic void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.ExternalizablereadExternal in class THashjava.io.IOExceptionjava.lang.ClassNotFoundException