当前位置: 首页>>代码示例>>Java>>正文


Java ConcurrentNavigableMap.subMap方法代码示例

本文整理汇总了Java中java.util.concurrent.ConcurrentNavigableMap.subMap方法的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentNavigableMap.subMap方法的具体用法?Java ConcurrentNavigableMap.subMap怎么用?Java ConcurrentNavigableMap.subMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.ConcurrentNavigableMap的用法示例。


在下文中一共展示了ConcurrentNavigableMap.subMap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSubMapContents2

import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
public void testSubMapContents2() {
    ConcurrentNavigableMap map = map5();
    SortedMap sm = map.subMap(two, three);
    assertEquals(1, sm.size());
    assertEquals(two, sm.firstKey());
    assertEquals(two, sm.lastKey());
    assertFalse(sm.containsKey(one));
    assertTrue(sm.containsKey(two));
    assertFalse(sm.containsKey(three));
    assertFalse(sm.containsKey(four));
    assertFalse(sm.containsKey(five));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(two, k);
    assertFalse(i.hasNext());
    Iterator j = sm.keySet().iterator();
    j.next();
    j.remove();
    assertFalse(map.containsKey(two));
    assertEquals(4, map.size());
    assertEquals(0, sm.size());
    assertTrue(sm.isEmpty());
    assertSame(sm.remove(three), null);
    assertEquals(4, map.size());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ConcurrentSkipListSubMapTest.java

示例2: testDescendingSubMapContents2

import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
public void testDescendingSubMapContents2() {
    ConcurrentNavigableMap map = dmap5();
    SortedMap sm = map.subMap(m2, m3);
    assertEquals(1, sm.size());
    assertEquals(m2, sm.firstKey());
    assertEquals(m2, sm.lastKey());
    assertFalse(sm.containsKey(m1));
    assertTrue(sm.containsKey(m2));
    assertFalse(sm.containsKey(m3));
    assertFalse(sm.containsKey(m4));
    assertFalse(sm.containsKey(m5));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(m2, k);
    assertFalse(i.hasNext());
    Iterator j = sm.keySet().iterator();
    j.next();
    j.remove();
    assertFalse(map.containsKey(m2));
    assertEquals(4, map.size());
    assertEquals(0, sm.size());
    assertTrue(sm.isEmpty());
    assertSame(sm.remove(m3), null);
    assertEquals(4, map.size());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ConcurrentSkipListSubMapTest.java

示例3: testSubMapContents

import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
 * subMap returns map with keys in requested range
 */
public void testSubMapContents() {
    ConcurrentNavigableMap map = map5();
    SortedMap sm = map.subMap(two, four);
    assertEquals(two, sm.firstKey());
    assertEquals(three, sm.lastKey());
    assertEquals(2, sm.size());
    assertFalse(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(two, k);
    k = (Integer)(i.next());
    assertEquals(three, k);
    assertFalse(i.hasNext());
    Iterator j = sm.keySet().iterator();
    j.next();
    j.remove();
    assertFalse(map.containsKey(two));
    assertEquals(4, map.size());
    assertEquals(1, sm.size());
    assertEquals(three, sm.firstKey());
    assertEquals(three, sm.lastKey());
    assertEquals("C", sm.remove(three));
    assertTrue(sm.isEmpty());
    assertEquals(3, map.size());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:ConcurrentSkipListSubMapTest.java

示例4: testDescendingSubMapContents

import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
 * subMap returns map with keys in requested range
 */
public void testDescendingSubMapContents() {
    ConcurrentNavigableMap map = dmap5();
    SortedMap sm = map.subMap(m2, m4);
    assertEquals(m2, sm.firstKey());
    assertEquals(m3, sm.lastKey());
    assertEquals(2, sm.size());
    assertFalse(sm.containsKey(m1));
    assertTrue(sm.containsKey(m2));
    assertTrue(sm.containsKey(m3));
    assertFalse(sm.containsKey(m4));
    assertFalse(sm.containsKey(m5));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer)(i.next());
    assertEquals(m2, k);
    k = (Integer)(i.next());
    assertEquals(m3, k);
    assertFalse(i.hasNext());
    Iterator j = sm.keySet().iterator();
    j.next();
    j.remove();
    assertFalse(map.containsKey(m2));
    assertEquals(4, map.size());
    assertEquals(1, sm.size());
    assertEquals(m3, sm.firstKey());
    assertEquals(m3, sm.lastKey());
    assertEquals("C", sm.remove(m3));
    assertTrue(sm.isEmpty());
    assertEquals(3, map.size());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:ConcurrentSkipListSubMapTest.java


注:本文中的java.util.concurrent.ConcurrentNavigableMap.subMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。