Code example for SortedMap

Methods: clearisEmptysize

0
    map.put("a", "value a");
    map.put("b", "value b");
    map.put("c", "value c");
 
    SortedMap<String, String> headMap = map.headMap("b");
    assertEquals("headMap.size", 1, headMap.size());
    assertEquals("headMap.isEmpty", false, headMap.isEmpty());
 
    headMap.clear();
    assertEquals("headMap.size", 0, headMap.size());
    assertEquals("headMap.isEmpty", true, headMap.isEmpty());
  } 
     
  public void testHeadMapEqualsFirst() { 
    SortedMap<String, String> sortedMap = createKnownKeysMap();
    SortedMap<String, String> subMap = sortedMap.headMap("aa");
    assertEquals("length", 0, subMap.size());
    Set<String> kset = subMap.keySet();
    Iterator<String> it = kset.iterator();
    assertFalse("iterator[0]", it.hasNext());