Package gnu.trove
Class TPrimitiveHash
- java.lang.Object
-
- gnu.trove.THash
-
- gnu.trove.TPrimitiveHash
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,java.lang.Cloneable
- Direct Known Subclasses:
TByteHash
,TDoubleHash
,TFloatHash
,TIntHash
,TLongHash
,TShortHash
public abstract class TPrimitiveHash extends THash
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. Created: Fri Jan 11 18:55:16 2002- Version:
- $Id: TPrimitiveHash.java,v 1.5 2008/10/08 16:39:10 robeden Exp $
- Author:
- Eric D. Friedman
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
_states
flags indicating whether each position in the hash is FREE, FULL, or REMOVEDprotected static byte
FREE
flag indicating that a slot in the hashtable is availableprotected static byte
FULL
flag indicating that a slot in the hashtable is occupiedprotected static byte
REMOVED
flag indicating that the value of a slot in the hashtable was deleted-
Fields inherited from class gnu.trove.THash
_autoCompactionFactor, _autoCompactRemovesRemaining, _free, _loadFactor, _maxSize, _size, DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR
-
-
Constructor Summary
Constructors Constructor Description TPrimitiveHash()
Creates a newTHash
instance with the default capacity and load factor.TPrimitiveHash(int initialCapacity)
Creates a newTPrimitiveHash
instance with a prime capacity at or near the specified capacity and with the default load factor.TPrimitiveHash(int initialCapacity, float loadFactor)
Creates a newTPrimitiveHash
instance with a prime capacity at or near the minimum needed to hold initialCapacity elements with load factor loadFactor without triggering a rehash.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
capacity()
Returns the capacity of the hash table.java.lang.Object
clone()
protected void
removeAt(int index)
Delete the record at index.protected int
setUp(int initialCapacity)
initializes the hashtable to a prime capacity which is at least initialCapacity + 1.-
Methods inherited from class gnu.trove.THash
calculateGrownCapacity, clear, compact, ensureCapacity, getAutoCompactionFactor, isEmpty, postInsertHook, readExternal, reenableAutoCompaction, rehash, setAutoCompactionFactor, size, tempDisableAutoCompaction, trimToSize, writeExternal
-
-
-
-
Field Detail
-
_states
protected transient byte[] _states
flags indicating whether each position in the hash is FREE, FULL, or REMOVED
-
FREE
protected static final byte FREE
flag indicating that a slot in the hashtable is available- See Also:
- Constant Field Values
-
FULL
protected static final byte FULL
flag indicating that a slot in the hashtable is occupied- See Also:
- Constant Field Values
-
REMOVED
protected static final byte REMOVED
flag indicating that the value of a slot in the hashtable was deleted- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TPrimitiveHash
public TPrimitiveHash()
Creates a newTHash
instance with the default capacity and load factor.
-
TPrimitiveHash
public TPrimitiveHash(int initialCapacity)
Creates a newTPrimitiveHash
instance with a prime capacity at or near the specified capacity and with the default load factor.- Parameters:
initialCapacity
- anint
value
-
TPrimitiveHash
public TPrimitiveHash(int initialCapacity, float loadFactor)
Creates a newTPrimitiveHash
instance with a prime capacity at or near the minimum needed to hold initialCapacity elements with load factor loadFactor without triggering a rehash.- Parameters:
initialCapacity
- anint
valueloadFactor
- afloat
value
-
-