Package java.util

Examples of java.util.IdentityHashMap.keySet()


    map.put("key", "value");
    map.put(null, null);
    map.put("a key", null);
    map.put("another key", null);

    Set keyset = map.keySet();
    Collection valueset = map.values();
    Set entries = map.entrySet();
    Iterator it = entries.iterator();
    while (it.hasNext()) {
      Map.Entry entry = (Map.Entry) it.next();
View Full Code Here


  public void test_keySet_clear() {
    IdentityHashMap map = new IdentityHashMap();
    for (int i = 0; i < 1000; i++) {
      map.put(new Integer(i), new Integer(i));
    }
    Set set = map.keySet();
    set.clear();

    assertEquals("did not remove all elements in the map", 0, map.size());
    assertTrue("did not remove all elements in the keyset", set.isEmpty());
View Full Code Here

  public void test_keySet_removeAll() {
    IdentityHashMap map = new IdentityHashMap();
    for (int i = 0; i < 1000; i++) {
      map.put(new Integer(i), new Integer(i));
    }
    Set set = map.keySet();
    set.removeAll(set);

    assertEquals("did not remove all elements in the map", 0, map.size());
    assertTrue("did not remove all elements in the keyset", set.isEmpty());
View Full Code Here

  public void test_keySet_retainAll() {
    IdentityHashMap map = new IdentityHashMap();
    for (int i = 0; i < 1000; i++) {
      map.put(new Integer(i), new Integer(i));
    }
    Set set = map.keySet();

    // retain all the elements
    boolean result = set.retainAll(set);
    assertTrue("retain all should return false", !result);
    assertEquals("did not retain all", 1000, set.size());
View Full Code Here

    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();
View Full Code Here

        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();
View Full Code Here

        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();
View Full Code Here

          .get(objArray2[counter]) == hm2.get(objArray2[counter]));

    IdentityHashMap map = new IdentityHashMap();
    map.put("key", "value");
    // get the keySet() and values() on the original Map
    Set keys = map.keySet();
    Collection values = map.values();
    assertEquals("values() does not work",
        "value", values.iterator().next());
    assertEquals("keySet() does not work",
        "key", keys.iterator().next());
View Full Code Here

          .contains(objArray2[i]));
    }

    IdentityHashMap m = new IdentityHashMap();
    m.put(null, "test");
    assertTrue("Failed with null key", m.keySet().contains(null));
    assertNull("Failed with null key", m.keySet().iterator().next());

    Map map = new IdentityHashMap(101);
    map.put(new Integer(1), "1");
    map.put(new Integer(102), "102");
View Full Code Here

    }

    IdentityHashMap m = new IdentityHashMap();
    m.put(null, "test");
    assertTrue("Failed with null key", m.keySet().contains(null));
    assertNull("Failed with null key", m.keySet().iterator().next());

    Map map = new IdentityHashMap(101);
    map.put(new Integer(1), "1");
    map.put(new Integer(102), "102");
    map.put(new Integer(203), "203");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.