當前位置: 首頁>>代碼示例>>Java>>正文


Java NavigableMap.clear方法代碼示例

本文整理匯總了Java中java.util.NavigableMap.clear方法的典型用法代碼示例。如果您正苦於以下問題:Java NavigableMap.clear方法的具體用法?Java NavigableMap.clear怎麽用?Java NavigableMap.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.NavigableMap的用法示例。


在下文中一共展示了NavigableMap.clear方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testHeadMapContents

import java.util.NavigableMap; //導入方法依賴的package包/類
/**
 * headMap returns map with keys in requested range
 */
public void testHeadMapContents() {
    ConcurrentSkipListMap map = map5();
    NavigableMap sm = map.headMap(four, false);
    assertTrue(sm.containsKey(one));
    assertTrue(sm.containsKey(two));
    assertTrue(sm.containsKey(three));
    assertFalse(sm.containsKey(four));
    assertFalse(sm.containsKey(five));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(one, k);
    k = (Integer)(i.next());
    assertEquals(two, k);
    k = (Integer)(i.next());
    assertEquals(three, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, map.size());
    assertEquals(four, map.firstKey());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:ConcurrentSkipListMapTest.java

示例2: testHeadMapContents

import java.util.NavigableMap; //導入方法依賴的package包/類
/**
 * headMap returns map with keys in requested range
 */
public void testHeadMapContents() {
    TreeMap map = map5();
    NavigableMap sm = map.headMap(four, false);
    assertTrue(sm.containsKey(one));
    assertTrue(sm.containsKey(two));
    assertTrue(sm.containsKey(three));
    assertFalse(sm.containsKey(four));
    assertFalse(sm.containsKey(five));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(one, k);
    k = (Integer)(i.next());
    assertEquals(two, k);
    k = (Integer)(i.next());
    assertEquals(three, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, map.size());
    assertEquals(four, map.firstKey());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:TreeMapTest.java

示例3: test_getVersions_String

import java.util.NavigableMap; //導入方法依賴的package包/類
@Test
public void test_getVersions_String() {
    NavigableMap<String, ZoneRules> versions = ZoneRulesProvider.getVersions("Europe/London");
    assertTrue(versions.size() >= 1);
    ZoneRules rules = ZoneRulesProvider.getRules("Europe/London", false);
    assertEquals(versions.lastEntry().getValue(), rules);

    NavigableMap<String, ZoneRules> copy = new TreeMap<>(versions);
    versions.clear();
    assertEquals(versions.size(), 0);
    NavigableMap<String, ZoneRules> versions2 = ZoneRulesProvider.getVersions("Europe/London");
    assertEquals(versions2, copy);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:TCKZoneRulesProvider.java

示例4: testSerialization

import java.util.NavigableMap; //導入方法依賴的package包/類
/**
 * A deserialized/reserialized map equals original
 */
public void testSerialization() throws Exception {
    NavigableMap x = map5();
    NavigableMap y = serialClone(x);

    assertNotSame(x, y);
    assertEquals(x.size(), y.size());
    assertEquals(x.toString(), y.toString());
    assertEquals(x, y);
    assertEquals(y, x);
    y.clear();
    assertTrue(y.isEmpty());
    assertFalse(x.equals(y));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:ConcurrentSkipListMapTest.java

示例5: testEquals

import java.util.NavigableMap; //導入方法依賴的package包/類
/**
 * Maps with same contents are equal
 */
public void testEquals() {
    NavigableMap map1 = map5();
    NavigableMap map2 = map5();
    assertEquals(map1, map2);
    assertEquals(map2, map1);
    map1.clear();
    assertFalse(map1.equals(map2));
    assertFalse(map2.equals(map1));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:TreeSubMapTest.java

示例6: testDescendingEquals

import java.util.NavigableMap; //導入方法依賴的package包/類
/**
 * Maps with same contents are equal
 */
public void testDescendingEquals() {
    NavigableMap map1 = dmap5();
    NavigableMap map2 = dmap5();
    assertEquals(map1, map2);
    assertEquals(map2, map1);
    map1.clear();
    assertFalse(map1.equals(map2));
    assertFalse(map2.equals(map1));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:TreeSubMapTest.java

示例7: testClear

import java.util.NavigableMap; //導入方法依賴的package包/類
/**
 * clear removes all pairs
 */
public void testClear() {
    NavigableMap map = map5();
    map.clear();
    assertEquals(0, map.size());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:TreeSubMapTest.java

示例8: testDescendingClear

import java.util.NavigableMap; //導入方法依賴的package包/類
/**
 * clear removes all pairs
 */
public void testDescendingClear() {
    NavigableMap map = dmap5();
    map.clear();
    assertEquals(0, map.size());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:TreeSubMapTest.java


注:本文中的java.util.NavigableMap.clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。