/[classpath]/classpath/java/util/Hashtable.java
ViewVC logotype

Diff of /classpath/java/util/Hashtable.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25 by mark, Sun Apr 7 12:20:58 2002 UTC revision 1.26 by mark, Mon Apr 8 00:38:48 2002 UTC
# Line 1  Line 1 
1  /* Hashtable.java -- a class providing a basic hashtable data structure,  /* Hashtable.java -- a class providing a basic hashtable data structure,
2     mapping Object --> Object     mapping Object --> Object
3     Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.     Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
4    
5  This file is part of GNU Classpath.  This file is part of GNU Classpath.
6    
# Line 102  import java.io.ObjectOutputStream; Line 102  import java.io.ObjectOutputStream;
102  public class Hashtable extends Dictionary  public class Hashtable extends Dictionary
103    implements Map, Cloneable, Serializable    implements Map, Cloneable, Serializable
104  {  {
105      // WARNING: Hashtable is a CORE class in the bootstrap cycle. See the
106      // comments in vm/reference/java/lang/Runtime for implications of this fact.
107    
108    /** Default number of buckets. This is the value the JDK 1.3 uses. Some    /** Default number of buckets. This is the value the JDK 1.3 uses. Some
109     * early documentation specified this value as 101. That is incorrect.     * early documentation specified this value as 101. That is incorrect.
110     */     */
# Line 176  public class Hashtable extends Dictionar Line 179  public class Hashtable extends Dictionar
179     * pair. A Hashtable Entry is identical to a HashMap Entry, except that     * pair. A Hashtable Entry is identical to a HashMap Entry, except that
180     * `null' is not allowed for keys and values.     * `null' is not allowed for keys and values.
181     */     */
182    private static final class HashEntry extends BasicMapEntry    private static final class HashEntry extends AbstractMap.BasicMapEntry
183    {    {
184      /** The next entry in the linked list. */      /** The next entry in the linked list. */
185      HashEntry next;      HashEntry next;
# Line 340  public class Hashtable extends Dictionar Line 343  public class Hashtable extends Dictionar
343     *     *
344     * @param value the value to search for in this Hashtable     * @param value the value to search for in this Hashtable
345     * @return true if at least one key maps to the value     * @return true if at least one key maps to the value
    * @throws NullPointerException if <code>value</code> is null  
346     * @see #contains(Object)     * @see #contains(Object)
347     * @see #containsKey(Object)     * @see #containsKey(Object)
348       * @throws NullPointerException if <code>value</code> is null
349     * @since 1.2     * @since 1.2
350     */     */
351    public boolean containsValue(Object value)    public boolean containsValue(Object value)
# Line 361  public class Hashtable extends Dictionar Line 364  public class Hashtable extends Dictionar
364      // Must throw on null argument even if the table is empty      // Must throw on null argument even if the table is empty
365      if (value == null)      if (value == null)
366        throw new NullPointerException();        throw new NullPointerException();
367    
368      return false;      return false;
369    }    }
370    
# Line 511  public class Hashtable extends Dictionar Line 514  public class Hashtable extends Dictionar
514        {        {
515          Map.Entry e = (Map.Entry) itr.next();          Map.Entry e = (Map.Entry) itr.next();
516          // Optimize in case the Entry is one of our own.          // Optimize in case the Entry is one of our own.
517          if (e instanceof BasicMapEntry)          if (e instanceof AbstractMap.BasicMapEntry)
518            {            {
519              BasicMapEntry entry = (BasicMapEntry) e;              AbstractMap.BasicMapEntry entry = (AbstractMap.BasicMapEntry) e;
520              put(entry.key, entry.value);              put(entry.key, entry.value);
521            }            }
522          else          else
# Line 812  public class Hashtable extends Dictionar Line 815  public class Hashtable extends Dictionar
815     */     */
816    private int hash(Object key)    private int hash(Object key)
817    {    {
818      return Math.abs(key.hashCode() % buckets.length);      // Note: Inline Math.abs here, for less method overhead, and to avoid
819        // a bootstrap dependency, since Math relies on native methods.
820        int hash = key.hashCode() % buckets.length;
821        return hash < 0 ? -hash : hash;
822    }    }
823    
824    /**    /**
# Line 1139  public class Hashtable extends Dictionar Line 1145  public class Hashtable extends Dictionar
1145        return type == VALUES ? e.value : e.key;        return type == VALUES ? e.value : e.key;
1146      }      }
1147    } // class Enumerator    } // class Enumerator
1148  }  } // class Hashtable

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26