< prev index next >

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

Print this page




  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  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.lang.reflect.Array;
  29 import java.util.function.BiConsumer;
  30 import java.util.function.BiFunction;
  31 import java.util.function.Consumer;
  32 import jdk.internal.misc.SharedSecrets;
  33 
  34 /**
  35  * This class implements the {@code Map} interface with a hash table, using
  36  * reference-equality in place of object-equality when comparing keys (and
  37  * values).  In other words, in an {@code IdentityHashMap}, two keys
  38  * {@code k1} and {@code k2} are considered equal if and only if
  39  * {@code (k1==k2)}.  (In normal {@code Map} implementations (like
  40  * {@code HashMap}) two keys {@code k1} and {@code k2} are considered equal
  41  * if and only if {@code (k1==null ? k2==null : k1.equals(k2))}.)
  42  *
  43  * <p><b>This class is <i>not</i> a general-purpose {@code Map}
  44  * implementation!  While this class implements the {@code Map} interface, it
  45  * intentionally violates {@code Map's} general contract, which mandates the
  46  * use of the {@code equals} method when comparing objects.  This class is
  47  * designed for use only in the rare cases wherein reference-equality
  48  * semantics are required.</b>
  49  *
  50  * <p>A typical use of this class is <i>topology-preserving object graph
  51  * transformations</i>, such as serialization or deep-copying.  To perform such
  52  * a transformation, a program must maintain a "node table" that keeps track




  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  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.lang.reflect.Array;
  29 import java.util.function.BiConsumer;
  30 import java.util.function.BiFunction;
  31 import java.util.function.Consumer;
  32 import jdk.internal.access.SharedSecrets;
  33 
  34 /**
  35  * This class implements the {@code Map} interface with a hash table, using
  36  * reference-equality in place of object-equality when comparing keys (and
  37  * values).  In other words, in an {@code IdentityHashMap}, two keys
  38  * {@code k1} and {@code k2} are considered equal if and only if
  39  * {@code (k1==k2)}.  (In normal {@code Map} implementations (like
  40  * {@code HashMap}) two keys {@code k1} and {@code k2} are considered equal
  41  * if and only if {@code (k1==null ? k2==null : k1.equals(k2))}.)
  42  *
  43  * <p><b>This class is <i>not</i> a general-purpose {@code Map}
  44  * implementation!  While this class implements the {@code Map} interface, it
  45  * intentionally violates {@code Map's} general contract, which mandates the
  46  * use of the {@code equals} method when comparing objects.  This class is
  47  * designed for use only in the rare cases wherein reference-equality
  48  * semantics are required.</b>
  49  *
  50  * <p>A typical use of this class is <i>topology-preserving object graph
  51  * transformations</i>, such as serialization or deep-copying.  To perform such
  52  * a transformation, a program must maintain a "node table" that keeps track


< prev index next >