THE PACKAGE JAVA.UTIL
java.util.Hashtable
21.5
21.5 The Class
java.util.Hashtable
. . . never did they seem to have new experiences in common . . . and the things
they had for dissection college, contemporary personality, and the like
they had hashed and rehashed for many a frugal conversational meal.
F. Scott Fitzgerald,
This Side of Paradise
(1920)
The class
Hashtable
implements the abstract class
Dictionary
( 21.4), with
some additional functionality.
public class Hashtable extends Dictionary implements Cloneable {
public Hashtable(int initialCapacity, float loadFactor);
public Hashtable(int initialCapacity);
public Hashtable();
public String toString();
public Object clone();
public int size();
public boolean isEmpty();
public Object get(Object key)
throws NullPointerException;
public Object put(Object key, Object value)
throws NullPointerException;
public Object remove(Object key)
throws NullPointerException;
public Enumeration keys();
public Enumeration elements();
public boolean contains(Object value);
public boolean containsKey(Object key);
protected void rehash();
public void clear();
}
A
Hashtable
has two parameters that affect its efficiency: its
capacity
and its
load factor
. The load factor should be between
0.0
and
1.0
. When the number of
entries in the hashtable exceeds the product of the load factor and the current
capacity, the capacity is increased, using the
rehash
method. Larger load factors
use memory more efficiently at the expense of larger expected time per lookup. If
many entries are to be made in a
Hashtable
, creating it with a sufficiently large
capacity may allow the entries to be inserted more efficiently than letting it per
form automatic rehashing as needed to grow the table.
635
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved