gnu.trove
Class TPrimitiveHash
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
$Id: TPrimitiveHash.java,v 1.4 2006/11/10 23:27:57 robeden Exp $protected static byte | FREE - flag indicating that a slot in the hashtable is available
|
protected static byte | FULL - flag indicating that a slot in the hashtable is occupied
|
protected static byte | REMOVED - flag indicating that the value of a slot in the hashtable
was deleted
|
protected byte[] | _states - flags indicating whether each position in the hash is
FREE, FULL, or REMOVED
|
TPrimitiveHash() - Creates a new
THash instance with the default
capacity and load factor.
|
TPrimitiveHash(int initialCapacity) - Creates a new
TPrimitiveHash instance with a prime
capacity at or near the specified capacity and with the default
load factor.
|
TPrimitiveHash(int initialCapacity, float loadFactor) - Creates a new
TPrimitiveHash instance with a prime
capacity at or near the minimum needed to hold
initialCapacity elements with load factor
loadFactor without triggering a rehash.
|
protected int | capacity() - Returns the capacity of the hash table.
|
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.
|
FREE
protected static final byte FREE
flag indicating that a slot in the hashtable is available
FULL
protected static final byte FULL
flag indicating that a slot in the hashtable is occupied
REMOVED
protected static final byte REMOVED
flag indicating that the value of a slot in the hashtable
was deleted
_states
protected byte[] _states
flags indicating whether each position in the hash is
FREE, FULL, or REMOVED
TPrimitiveHash
public TPrimitiveHash()
Creates a new THash
instance with the default
capacity and load factor.
TPrimitiveHash
public TPrimitiveHash(int initialCapacity)
Creates a new TPrimitiveHash
instance with a prime
capacity at or near the specified capacity and with the default
load factor.
initialCapacity
- an int
value
TPrimitiveHash
public TPrimitiveHash(int initialCapacity,
float loadFactor)
Creates a new TPrimitiveHash
instance with a prime
capacity at or near the minimum needed to hold
initialCapacity elements with load factor
loadFactor without triggering a rehash.
initialCapacity
- an int
valueloadFactor
- a float
value
capacity
protected int capacity()
Returns the capacity of the hash table. This is the true
physical capacity, without adjusting for the load factor.
- the physical capacity of the hash table.
clone
public Object clone()
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.
initialCapacity
- an int
value
- the actual capacity chosen
GNU Trove is copyright B) 2001-2008 Eric D. Friedman. All Rights Reserved.