< prev index next >

src/java.base/share/classes/java/util/HashMap.java

Print this page




  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.util;
  27 
  28 import java.io.IOException;
  29 import java.io.InvalidObjectException;
  30 import java.io.Serializable;
  31 import java.lang.reflect.ParameterizedType;
  32 import java.lang.reflect.Type;
  33 import java.util.function.BiConsumer;
  34 import java.util.function.BiFunction;
  35 import java.util.function.Consumer;
  36 import java.util.function.Function;
  37 import jdk.internal.misc.SharedSecrets;
  38 
  39 /**
  40  * Hash table based implementation of the {@code Map} interface.  This
  41  * implementation provides all of the optional map operations, and permits
  42  * {@code null} values and the {@code null} key.  (The {@code HashMap}
  43  * class is roughly equivalent to {@code Hashtable}, except that it is
  44  * unsynchronized and permits nulls.)  This class makes no guarantees as to
  45  * the order of the map; in particular, it does not guarantee that the order
  46  * will remain constant over time.
  47  *
  48  * <p>This implementation provides constant-time performance for the basic
  49  * operations ({@code get} and {@code put}), assuming the hash function
  50  * disperses the elements properly among the buckets.  Iteration over
  51  * collection views requires time proportional to the "capacity" of the
  52  * {@code HashMap} instance (the number of buckets) plus its size (the number
  53  * of key-value mappings).  Thus, it's very important not to set the initial
  54  * capacity too high (or the load factor too low) if iteration performance is
  55  * important.
  56  *
  57  * <p>An instance of {@code HashMap} has two parameters that affect its




  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.util;
  27 
  28 import java.io.IOException;
  29 import java.io.InvalidObjectException;
  30 import java.io.Serializable;
  31 import java.lang.reflect.ParameterizedType;
  32 import java.lang.reflect.Type;
  33 import java.util.function.BiConsumer;
  34 import java.util.function.BiFunction;
  35 import java.util.function.Consumer;
  36 import java.util.function.Function;
  37 import jdk.internal.access.SharedSecrets;
  38 
  39 /**
  40  * Hash table based implementation of the {@code Map} interface.  This
  41  * implementation provides all of the optional map operations, and permits
  42  * {@code null} values and the {@code null} key.  (The {@code HashMap}
  43  * class is roughly equivalent to {@code Hashtable}, except that it is
  44  * unsynchronized and permits nulls.)  This class makes no guarantees as to
  45  * the order of the map; in particular, it does not guarantee that the order
  46  * will remain constant over time.
  47  *
  48  * <p>This implementation provides constant-time performance for the basic
  49  * operations ({@code get} and {@code put}), assuming the hash function
  50  * disperses the elements properly among the buckets.  Iteration over
  51  * collection views requires time proportional to the "capacity" of the
  52  * {@code HashMap} instance (the number of buckets) plus its size (the number
  53  * of key-value mappings).  Thus, it's very important not to set the initial
  54  * capacity too high (or the load factor too low) if iteration performance is
  55  * important.
  56  *
  57  * <p>An instance of {@code HashMap} has two parameters that affect its


< prev index next >