jrunx.util
Class FlatHashtable

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--jrunx.util.FlatHashtable
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable
Direct Known Subclasses:
MultiKeyContainer

public class FlatHashtable
extends java.util.Hashtable

flat hashtable implementation. This implemenation uses two flat arrays to hold elements, and uses double hashing instead of chaining. It also contains an add() method which allows multiple values to be stored on a particlar key.

See Also:
Serialized Form

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
protected  java.lang.Object[] keys
           
protected static int loadFactor
           
protected  int removed
          number of elements that have been removed.
protected static java.lang.Object REMOVED
           
protected  int size
          number of active elements in the hash
protected  java.lang.Object[] values
           
 
Constructor Summary
FlatHashtable()
          most places we use a hashtable, it will be empty or nearly empty, so the default capacity will be very small to conserve memory.
FlatHashtable(int capacity)
           
 
Method Summary
 void clear()
          empty out the hashtable
 boolean contains(java.lang.Object value)
          This method is not to be confused with containsKey
 boolean containsKey(java.lang.Object key)
          returns whether this key is in the hash table.
 java.util.Enumeration elements()
           
protected  int find(java.lang.Object key)
          find the key given, or the first empty slot
 java.lang.Object get(java.lang.Object key)
           
 boolean isEmpty()
           
 java.util.Enumeration keys()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
protected  void rehash()
           
 java.lang.Object remove(java.lang.Object key)
           
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class java.util.Hashtable
clone, containsValue, entrySet, equals, hashCode, keySet, putAll, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

keys

protected java.lang.Object[] keys

values

protected java.lang.Object[] values

REMOVED

protected static final java.lang.Object REMOVED

loadFactor

protected static final int loadFactor

size

protected int size
number of active elements in the hash

removed

protected int removed
number of elements that have been removed.
Constructor Detail

FlatHashtable

public FlatHashtable()
most places we use a hashtable, it will be empty or nearly empty, so the default capacity will be very small to conserve memory. The current default size is 11.

FlatHashtable

public FlatHashtable(int capacity)
Method Detail

find

protected int find(java.lang.Object key)
find the key given, or the first empty slot

get

public java.lang.Object get(java.lang.Object key)
Overrides:
get in class java.util.Hashtable
Returns:
the value for this key, or null if the key does not exist.

rehash

protected void rehash()
Overrides:
rehash in class java.util.Hashtable

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Overrides:
put in class java.util.Hashtable

remove

public java.lang.Object remove(java.lang.Object key)
Overrides:
remove in class java.util.Hashtable

containsKey

public boolean containsKey(java.lang.Object key)
returns whether this key is in the hash table. Since you can store null values, this is what you want to call to test if a value exists or not.
Overrides:
containsKey in class java.util.Hashtable

contains

public boolean contains(java.lang.Object value)
This method is not to be confused with containsKey
Overrides:
contains in class java.util.Hashtable
Returns:
a boolean indicating whether this hashtable contains this value

clear

public void clear()
empty out the hashtable
Overrides:
clear in class java.util.Hashtable

size

public int size()
Overrides:
size in class java.util.Hashtable

isEmpty

public boolean isEmpty()
Overrides:
isEmpty in class java.util.Hashtable

keys

public java.util.Enumeration keys()
Overrides:
keys in class java.util.Hashtable

elements

public java.util.Enumeration elements()
Overrides:
elements in class java.util.Hashtable

toString

public java.lang.String toString()
Overrides:
toString in class java.util.Hashtable


Copyright � 2002 Macromedia Corporation. All Rights Reserved.