Search in sources :

Example 71 with IdentityHashMap

use of java.util.IdentityHashMap in project j2objc by google.

the class AbstractMapTest method test_keySet.

/**
     * @tests java.util.AbstractMap#keySet()
     */
public void test_keySet() {
    AbstractMap map1 = new HashMap(0);
    assertSame("HashMap(0)", map1.keySet(), map1.keySet());
    AbstractMap map2 = new HashMap(10);
    assertSame("HashMap(10)", map2.keySet(), map2.keySet());
    Map map3 = Collections.EMPTY_MAP;
    assertSame("EMPTY_MAP", map3.keySet(), map3.keySet());
    AbstractMap map4 = new IdentityHashMap(1);
    assertSame("IdentityHashMap", map4.keySet(), map4.keySet());
    AbstractMap map5 = new LinkedHashMap(122);
    assertSame("LinkedHashMap", map5.keySet(), map5.keySet());
    AbstractMap map6 = new TreeMap();
    assertSame("TreeMap", map6.keySet(), map6.keySet());
}
Also used : AbstractMap(java.util.AbstractMap) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IdentityHashMap(java.util.IdentityHashMap) TreeMap(java.util.TreeMap) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) AbstractMap(java.util.AbstractMap) TreeMap(java.util.TreeMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 72 with IdentityHashMap

use of java.util.IdentityHashMap in project j2objc by google.

the class AbstractMapTest method test_values.

/**
     * @tests java.util.AbstractMap#values()
     */
public void test_values() {
    AbstractMap map1 = new HashMap(0);
    assertSame("HashMap(0)", map1.values(), map1.values());
    AbstractMap map2 = new HashMap(10);
    assertSame("HashMap(10)", map2.values(), map2.values());
    Map map3 = Collections.EMPTY_MAP;
    assertSame("EMPTY_MAP", map3.values(), map3.values());
    AbstractMap map4 = new IdentityHashMap(1);
    assertSame("IdentityHashMap", map4.values(), map4.values());
    AbstractMap map5 = new LinkedHashMap(122);
    assertSame("IdentityHashMap", map5.values(), map5.values());
    AbstractMap map6 = new TreeMap();
    assertSame("TreeMap", map6.values(), map6.values());
}
Also used : AbstractMap(java.util.AbstractMap) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IdentityHashMap(java.util.IdentityHashMap) TreeMap(java.util.TreeMap) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) AbstractMap(java.util.AbstractMap) TreeMap(java.util.TreeMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 73 with IdentityHashMap

use of java.util.IdentityHashMap in project j2objc by google.

the class IdentityHashMapTest method test_keyset_remove.

/**
	 * @tests java.util.IdentityHashMap#keySet()
	 * @tests java.util.IdentityHashMap#remove(java.lang.Object)
	 */
public void test_keyset_remove() {
    IdentityHashMap map = new IdentityHashMap();
    Integer key = new Integer(21);
    map.put(new Integer(1), null);
    map.put(new Integer(11), null);
    map.put(key, null);
    map.put(new Integer(31), null);
    map.put(new Integer(41), null);
    map.put(new Integer(51), null);
    map.put(new Integer(61), null);
    map.put(new Integer(71), null);
    map.put(new Integer(81), null);
    map.put(new Integer(91), null);
    Set set = map.keySet();
    Set newset = new HashSet();
    Iterator it = set.iterator();
    while (it.hasNext()) {
        Object element = it.next();
        if (element == key) {
            it.remove();
        } else
            newset.add(element);
    }
    int size = newset.size();
    assertTrue("keyset and newset don't have same size", newset.size() == size);
    assertTrue("element is in newset ", !newset.contains(key));
    assertTrue("element not removed from keyset", !set.contains(key));
    assertTrue("element not removed from map", !map.containsKey(key));
    assertTrue("newset and keyset do not have same elements 1", newset.equals(set));
    assertTrue("newset and keyset do not have same elements 2", set.equals(newset));
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) TreeSet(java.util.TreeSet) IdentityHashMap(java.util.IdentityHashMap) Iterator(java.util.Iterator) HashSet(java.util.HashSet)

Example 74 with IdentityHashMap

use of java.util.IdentityHashMap in project j2objc by google.

the class IdentityHashMapTest method test_clone_scenario4.

public void test_clone_scenario4() {
    IdentityHashMap hashMap = new IdentityHashMap();
    Object cloneHashMap = hashMap.clone();
    assertNull(((IdentityHashMap) cloneHashMap).get((Object) null));
    hashMap.put((Object) null, cloneHashMap);
    assertNull(((IdentityHashMap) cloneHashMap).get((Object) null));
    assertEquals(cloneHashMap, hashMap.get((Object) null));
}
Also used : IdentityHashMap(java.util.IdentityHashMap)

Example 75 with IdentityHashMap

use of java.util.IdentityHashMap in project j2objc by google.

the class IdentityHashMapTest method test_clone_scenario2.

public void test_clone_scenario2() {
    IdentityHashMap hashMap = new IdentityHashMap();
    assertEquals(0, hashMap.hashCode());
    Object cloneHashMap = hashMap.clone();
    hashMap.put("key", "value");
    assertEquals(1, hashMap.size());
    assertEquals(0, ((IdentityHashMap) cloneHashMap).size());
    assertEquals("value", hashMap.get("key"));
    assertNull(((IdentityHashMap) cloneHashMap).get("key"));
    assertTrue(0 != hashMap.hashCode());
    assertEquals(0, cloneHashMap.hashCode());
}
Also used : IdentityHashMap(java.util.IdentityHashMap)

Aggregations

IdentityHashMap (java.util.IdentityHashMap)131 Map (java.util.Map)43 HashMap (java.util.HashMap)38 ArrayList (java.util.ArrayList)27 HashSet (java.util.HashSet)19 LinkedHashMap (java.util.LinkedHashMap)17 Collection (java.util.Collection)16 Set (java.util.Set)16 TreeMap (java.util.TreeMap)16 Iterator (java.util.Iterator)14 AbstractMap (java.util.AbstractMap)13 Test (org.junit.Test)11 DependencyNode (org.sonatype.aether.graph.DependencyNode)10 WeakHashMap (java.util.WeakHashMap)8 LinkedList (java.util.LinkedList)7 List (java.util.List)7 TreeSet (java.util.TreeSet)7 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7 Tree (edu.stanford.nlp.trees.Tree)6 Entry (java.util.Map.Entry)5