* @author Jon Zeppieri
* @author Jochen Hoenicke
* @author Bryce McKinlay
- * @version $Revision: 1.4 $
- * @modified $Id: HashMap.java,v 1.4 2000/12/21 02:00:15 bryce Exp $
*/
public class HashMap extends AbstractMap
implements Map, Cloneable, Serializable
*
* @throws IllegalArgumentException if (initialCapacity < 0) ||
* (initialLoadFactor > 1.0) ||
- * (initialLoadFactor <= 0.0)
*/
public HashMap(int initialCapacity, float loadFactor)
throws IllegalArgumentException
{
- if (initialCapacity < 0 || loadFactor <= 0 || loadFactor > 1)
- throw new IllegalArgumentException();
-
+ if (initialCapacity < 0)
+ throw new IllegalArgumentException("Illegal Initial Capacity: "
+ + initialCapacity);
+ if (loadFactor <= 0)
+ throw new IllegalArgumentException("Illegal Load Factor: " + loadFactor);
+
buckets = new Entry[initialCapacity];
this.loadFactor = loadFactor;
this.threshold = (int) (initialCapacity * loadFactor);
* keys, values, or entries.
*
* @author Jon Zeppieri
- * @version $Revision: 1.4 $
- * @modified $Id: HashMap.java,v 1.4 2000/12/21 02:00:15 bryce Exp $
*/
class HashIterator implements Iterator
{
* @author Jon Zeppieri
* @author Warren Levy
* @author Bryce McKinlay
- * @version $Revision: 1.9 $
- * @modified $Id: Hashtable.java,v 1.9 2000/12/17 09:15:51 bryce Exp $
*/
public class Hashtable extends Dictionary
implements Map, Cloneable, Serializable
* @param loadFactor the load factor
*
* @throws IllegalArgumentException if (initialCapacity < 0) ||
- * (initialLoadFactor > 1.0) ||
* (initialLoadFactor <= 0.0)
*/
public Hashtable(int initialCapacity, float loadFactor)
throws IllegalArgumentException
{
- if (initialCapacity < 0 || loadFactor <= 0 || loadFactor > 1)
- throw new IllegalArgumentException();
-
+ if (initialCapacity < 0)
+ throw new IllegalArgumentException("Illegal Initial Capacity: "
+ + initialCapacity);
+ if (loadFactor <= 0)
+ throw new IllegalArgumentException("Illegal Load Factor: " + loadFactor);
+
buckets = new Entry[initialCapacity];
this.loadFactor = loadFactor;
this.threshold = (int) (initialCapacity * loadFactor);
* as per the Javasoft spec.
*
* @author Jon Zeppieri
- * @version $Revision: 1.9 $
- * @modified $Id: Hashtable.java,v 1.9 2000/12/17 09:15:51 bryce Exp $
*/
class HashIterator implements Iterator
{
* elements; this implementation is parameterized to provide access either
* to the keys or to the values in the Hashtable.
*
- * <b>NOTE: Enumeration is not safe if new elements are put in the table as
- * this could cause a rehash and we'd completely lose our place. Even
+ * <b>NOTE</b>: Enumeration is not safe if new elements are put in the table
+ * as this could cause a rehash and we'd completely lose our place. Even
* without a rehash, it is undetermined if a new element added would
* appear in the enumeration. The spec says nothing about this, but
* the "Java Class Libraries" book infers that modifications to the
* hashtable during enumeration causes indeterminate results. Don't do it!
*
* @author Jon Zeppieri
- * @version $Revision: 1.9 $
- * @modified $Id: Hashtable.java,v 1.9 2000/12/17 09:15:51 bryce Exp $ */
+ */
class Enumerator implements Enumeration
{
static final int KEYS = 0;