All Packages Class Hierarchy This Package Previous Next Index
Class com.micronova.util.IXHashtable
java.lang.Object
|
+----com.micronova.util.IXVector
|
+----com.micronova.util.IXHashtable
- public abstract class IXHashtable
- extends IXVector
IXHashtable implements value-type-independent double-hashing Hashtable.
- Version:
- 1.0
-
_codes
- Contains hashcodes.
-
_keys
- Contains keys.
-
_level
- Index such that the array size is equal to primes[level].
-
_maxCount
- Max number of elements to be held without rehashing.
-
_threshold
- Threshold percentage.
-
primes
- prime numbers close to 2^n.
-
IXHashtable()
- Construct an IXHashtable with 75% threshold (default).
-
IXHashtable(int, int)
- Construct an IHashtable with given capacity and threshold.
-
_computeLevel(int)
- Returns index such that primes[index] is greater than given size.
-
_get(Object, int)
- Returns the index for the given key (where the corresponding value can be retrieved).
-
_getHash(Object)
- Computes hashcode for a given key.
-
_locate(Object[], int[], Object, int, boolean)
- Locates given 'key' with hashcode 'h' and returns its index in the given keys[] and codes[] arrays.
-
_put(Object, int)
- Puts a key with given hashcode and returns its index (where the corresponding value should be stored).
-
_rehash(int, int)
- Rehashes to newLength and returns an array of indices for value re-mapping.
-
_remove(Object, int)
- Removes a key and returns the index (from where the corresponding value must be removed).
-
_setLevel(int)
- Initialize to given level.
primes
protected static int primes[]
- prime numbers close to 2^n. IXHashtable size is always a prime number.
_codes
protected int _codes[]
- Contains hashcodes. Contains 0 if the slot is empty, -1 if an element is removed.
_keys
protected Object _keys[]
- Contains keys.
_level
protected int _level
- Index such that the array size is equal to primes[level]. This is incremented on rehashing.
_maxCount
protected int _maxCount
- Max number of elements to be held without rehashing.
_threshold
protected int _threshold
- Threshold percentage. 'maxCount' is set to 'length * threshold / 100'.
IXHashtable
public IXHashtable()
- Construct an IXHashtable with 75% threshold (default).
IXHashtable
public IXHashtable(int capacity,
int threshold)
- Construct an IHashtable with given capacity and threshold. IHashtable constructed this way holds given 'capacity' elements without rehashing.
_computeLevel
protected final int _computeLevel(int size)
- Returns index such that primes[index] is greater than given size.
_getHash
protected int _getHash(Object key)
- Computes hashcode for a given key. Always returns a positive (non-zero) number.
_locate
protected static final int _locate(Object keys[],
int codes[],
Object key,
int h,
boolean doPut)
- Locates given 'key' with hashcode 'h' and returns its index in the given keys[] and codes[] arrays. If 'doPut' is true, returns the first empty slot index if given key is not found. If 'doPut' is false, returns -1 if key is not found.
_setLevel
protected void _setLevel(int level)
- Initialize to given level.
_rehash
protected final int[] _rehash(int newLength,
int currentLength)
- Rehashes to newLength and returns an array of indices for value re-mapping. _codes and _keys are resized and rehashed after this operation. Returns an integer array x[] of currentLength indicating that a value at index i should be moved to index x[i] after resizing if x[i] is not negative. This sets _length.
_put
protected final int _put(Object key,
int h)
- Puts a key with given hashcode and returns its index (where the corresponding value should be stored).
_get
protected final int _get(Object key,
int h)
- Returns the index for the given key (where the corresponding value can be retrieved). Returns -1 if key is not found.
_remove
protected final int _remove(Object key,
int h)
- Removes a key and returns the index (from where the corresponding value must be removed). Returns -1 if key is not found.
All Packages Class Hierarchy This Package Previous Next Index