当前位置: 首页>>代码示例>>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;未经允许,请勿转载。