Package gnu.trove.impl.hash
Class TPrimitiveHash
java.lang.Object
gnu.trove.impl.hash.THash
gnu.trove.impl.hash.TPrimitiveHash
- All Implemented Interfaces:
Externalizable,Serializable
- Direct Known Subclasses:
TByteByteHash,TByteCharHash,TByteDoubleHash,TByteFloatHash,TByteHash,TByteIntHash,TByteLongHash,TByteShortHash,TCharByteHash,TCharCharHash,TCharDoubleHash,TCharFloatHash,TCharHash,TCharIntHash,TCharLongHash,TCharShortHash,TDoubleByteHash,TDoubleCharHash,TDoubleDoubleHash,TDoubleFloatHash,TDoubleHash,TDoubleIntHash,TDoubleLongHash,TDoubleShortHash,TFloatByteHash,TFloatCharHash,TFloatDoubleHash,TFloatFloatHash,TFloatHash,TFloatIntHash,TFloatLongHash,TFloatShortHash,TIntByteHash,TIntCharHash,TIntDoubleHash,TIntFloatHash,TIntHash,TIntIntHash,TIntLongHash,TIntShortHash,TLongByteHash,TLongCharHash,TLongDoubleHash,TLongFloatHash,TLongHash,TLongIntHash,TLongLongHash,TLongShortHash,TShortByteHash,TShortCharHash,TShortDoubleHash,TShortFloatHash,TShortHash,TShortIntHash,TShortLongHash,TShortShortHash
The base class for hashtables of primitive values. Since there is
no notion of object equality for primitives, it isn't possible to
use a `REMOVED' object to track deletions in an open-addressed table.
So, we have to resort to using a parallel `bookkeeping' array of bytes,
in which flags can be set to indicate that a particular slot in the
hash table is FREE, FULL, or REMOVED.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionbyte[]flags indicating whether each position in the hash is FREE, FULL, or REMOVEDstatic final byteflag indicating that a slot in the hashtable is availablestatic final byteflag indicating that a slot in the hashtable is occupiedstatic final byteflag indicating that the value of a slot in the hashtable was deletedFields inherited from class gnu.trove.impl.hash.THash
_autoCompactionFactor, _autoCompactRemovesRemaining, _autoCompactTemporaryDisable, _free, _loadFactor, _maxSize, _size, DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newTHashinstance with the default capacity and load factor.TPrimitiveHash(int initialCapacity) Creates a newTPrimitiveHashinstance with a prime capacity at or near the specified capacity and with the default load factor.TPrimitiveHash(int initialCapacity, float loadFactor) Creates a newTPrimitiveHashinstance with a prime capacity at or near the minimum needed to hold initialCapacity elements with load factor loadFactor without triggering a rehash. -
Method Summary
Methods inherited from class gnu.trove.impl.hash.THash
calculateGrownCapacity, clear, compact, computeMaxSize, computeNextAutoCompactionAmount, ensureCapacity, fastCeil, getAutoCompactionFactor, isEmpty, postInsertHook, readExternal, reenableAutoCompaction, rehash, saturatedCast, setAutoCompactionFactor, size, tempDisableAutoCompaction, trimToSize, writeExternal
-
Field Details
-
_states
public transient byte[] _statesflags indicating whether each position in the hash is FREE, FULL, or REMOVED -
FREE
public static final byte FREEflag indicating that a slot in the hashtable is available- See Also:
-
FULL
public static final byte FULLflag indicating that a slot in the hashtable is occupied- See Also:
-
REMOVED
public static final byte REMOVEDflag indicating that the value of a slot in the hashtable was deleted- See Also:
-
-
Constructor Details
-
TPrimitiveHash
public TPrimitiveHash()Creates a newTHashinstance with the default capacity and load factor. -
TPrimitiveHash
public TPrimitiveHash(int initialCapacity) Creates a newTPrimitiveHashinstance with a prime capacity at or near the specified capacity and with the default load factor.- Parameters:
initialCapacity- anintvalue
-
TPrimitiveHash
public TPrimitiveHash(int initialCapacity, float loadFactor) Creates a newTPrimitiveHashinstance with a prime capacity at or near the minimum needed to hold initialCapacity elements with load factor loadFactor without triggering a rehash.- Parameters:
initialCapacity- anintvalueloadFactor- afloatvalue
-
-
Method Details
-
capacity
public int capacity()Returns the capacity of the hash table. This is the true physical capacity, without adjusting for the load factor. -
removeAt
protected void removeAt(int index) Delete the record at index. -
setUp
protected int setUp(int initialCapacity) initializes the hashtable to a prime capacity which is at least initialCapacity + 1.
-