Example usage for java.util IdentityHashMap equals

List of usage examples for java.util IdentityHashMap equals

Introduction

In this page you can find the example usage for java.util IdentityHashMap equals.

Prototype

public boolean equals(Object o) 

Source Link

Document

Compares the specified object with this map for equality.

Usage

From source file:com.google.gwt.emultest.java.util.IdentityHashMapTest.java

public void testEquals() {
    IdentityHashMap hashMap = new IdentityHashMap();
    checkEmptyHashMapAssumptions(hashMap);

    hashMap.put(KEY_KEY, VALUE_VAL);//from  w  ww  .j  av  a  2 s. c  o m

    IdentityHashMap copyMap = (IdentityHashMap) hashMap.clone();

    assertTrue(hashMap.equals(copyMap));
    hashMap.put(VALUE_VAL, KEY_KEY);
    assertFalse(hashMap.equals(copyMap));
}

From source file:com.google.gwt.emultest.java.util.IdentityHashMapTest.java

/**
 * Test that the implementation differs from a standard map in demanding
 * identity./*from w  w w. jav  a2 s  . c  o m*/
 */
public void testIdentityBasedEquality() {
    IdentityHashMap hashMap1 = new IdentityHashMap();
    checkEmptyHashMapAssumptions(hashMap1);

    IdentityHashMap hashMap2 = new IdentityHashMap();
    checkEmptyHashMapAssumptions(hashMap2);

    hashMap1.put(new Foo(), VALUE_1);
    hashMap2.put(new Foo(), VALUE_1);
    assertFalse(hashMap1.equals(hashMap2));
}