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


Java ConcurrentNavigableMap.put方法代码示例

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


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

示例1: testPollFirstEntry

import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
 * pollFirstEntry returns entries in order
 */
public void testPollFirstEntry() {
    ConcurrentNavigableMap map = map5();
    Map.Entry e = map.pollFirstEntry();
    assertEquals(one, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(two, e.getKey());
    map.put(one, "A");
    e = map.pollFirstEntry();
    assertEquals(one, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(three, e.getKey());
    map.remove(four);
    e = map.pollFirstEntry();
    assertEquals(five, e.getKey());
    try {
        e.setValue("A");
        shouldThrow();
    } catch (UnsupportedOperationException success) {}
    e = map.pollFirstEntry();
    assertNull(e);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ConcurrentSkipListSubMapTest.java

示例2: testPollLastEntry

import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
 * pollLastEntry returns entries in order
 */
public void testPollLastEntry() {
    ConcurrentNavigableMap map = map5();
    Map.Entry e = map.pollLastEntry();
    assertEquals(five, e.getKey());
    assertEquals("E", e.getValue());
    e = map.pollLastEntry();
    assertEquals(four, e.getKey());
    map.put(five, "E");
    e = map.pollLastEntry();
    assertEquals(five, e.getKey());
    assertEquals("E", e.getValue());
    e = map.pollLastEntry();
    assertEquals(three, e.getKey());
    map.remove(two);
    e = map.pollLastEntry();
    assertEquals(one, e.getKey());
    try {
        e.setValue("E");
        shouldThrow();
    } catch (UnsupportedOperationException success) {}
    e = map.pollLastEntry();
    assertNull(e);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ConcurrentSkipListSubMapTest.java

示例3: testDescendingPollFirstEntry

import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
 * pollFirstEntry returns entries in order
 */
public void testDescendingPollFirstEntry() {
    ConcurrentNavigableMap map = dmap5();
    Map.Entry e = map.pollFirstEntry();
    assertEquals(m1, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(m2, e.getKey());
    map.put(m1, "A");
    e = map.pollFirstEntry();
    assertEquals(m1, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(m3, e.getKey());
    map.remove(m4);
    e = map.pollFirstEntry();
    assertEquals(m5, e.getKey());
    try {
        e.setValue("A");
        shouldThrow();
    } catch (UnsupportedOperationException success) {}
    e = map.pollFirstEntry();
    assertNull(e);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ConcurrentSkipListSubMapTest.java

示例4: testDescendingPollLastEntry

import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
 * pollLastEntry returns entries in order
 */
public void testDescendingPollLastEntry() {
    ConcurrentNavigableMap map = dmap5();
    Map.Entry e = map.pollLastEntry();
    assertEquals(m5, e.getKey());
    assertEquals("E", e.getValue());
    e = map.pollLastEntry();
    assertEquals(m4, e.getKey());
    map.put(m5, "E");
    e = map.pollLastEntry();
    assertEquals(m5, e.getKey());
    assertEquals("E", e.getValue());
    e = map.pollLastEntry();
    assertEquals(m3, e.getKey());
    map.remove(m2);
    e = map.pollLastEntry();
    assertEquals(m1, e.getKey());
    try {
        e.setValue("E");
        shouldThrow();
    } catch (UnsupportedOperationException success) {}
    e = map.pollLastEntry();
    assertNull(e);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ConcurrentSkipListSubMapTest.java

示例5: test

import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
     * 测试provider注册
     */
    public void test(DB db) {

        
                //create new collection (or open existing)
                ConcurrentNavigableMap map = db.getTreeMap("collectionName");
                map.put(1,"one");
                map.put(new Random().nextInt(25500),"bnt_test" + new Random().nextInt(25005));
                //persist changes into disk, there is also rollback() method
                db.commit();
//                db.close();
                cnt.incrementAndGet();
    }
 
开发者ID:tiglabs,项目名称:jsf-core,代码行数:16,代码来源:TestMapDB.java

示例6: testPut1_NullPointerException

import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
 * put(null,x) throws NPE
 */
public void testPut1_NullPointerException() {
    try {
        ConcurrentNavigableMap c = map5();
        c.put(null, "whatever");
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ConcurrentSkipListSubMapTest.java

示例7: testDescendingPut1_NullPointerException

import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
 * put(null,x) throws NPE
 */
public void testDescendingPut1_NullPointerException() {
    try {
        ConcurrentNavigableMap c = dmap5();
        c.put(null, "whatever");
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ConcurrentSkipListSubMapTest.java

示例8: updateLastFlushedSequenceIds

import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
 * Updates last flushed sequence Ids for the regions on server sn
 * @param sn
 * @param hsl
 */
private void updateLastFlushedSequenceIds(ServerName sn, ServerLoad hsl) {
  Map<byte[], RegionLoad> regionsLoad = hsl.getRegionsLoad();
  for (Entry<byte[], RegionLoad> entry : regionsLoad.entrySet()) {
    byte[] encodedRegionName = Bytes.toBytes(HRegionInfo.encodeRegionName(entry.getKey()));
    Long existingValue = flushedSequenceIdByRegion.get(encodedRegionName);
    long l = entry.getValue().getCompleteSequenceId();
    // Don't let smaller sequence ids override greater sequence ids.
    if (LOG.isTraceEnabled()) {
      LOG.trace(Bytes.toString(encodedRegionName) + ", existingValue=" + existingValue +
        ", completeSequenceId=" + l);
    }
    if (existingValue == null || (l != HConstants.NO_SEQNUM && l > existingValue)) {
      flushedSequenceIdByRegion.put(encodedRegionName, l);
    } else if (l != HConstants.NO_SEQNUM && l < existingValue) {
      LOG.warn("RegionServer " + sn + " indicates a last flushed sequence id ("
          + l + ") that is less than the previous last flushed sequence id ("
          + existingValue + ") for region " + Bytes.toString(entry.getKey()) + " Ignoring.");
    }
    ConcurrentNavigableMap<byte[], Long> storeFlushedSequenceId =
        getOrCreateStoreFlushedSequenceId(encodedRegionName);
    for (StoreSequenceId storeSeqId : entry.getValue().getStoreCompleteSequenceId()) {
      byte[] family = storeSeqId.getFamilyName().toByteArray();
      existingValue = storeFlushedSequenceId.get(family);
      l = storeSeqId.getSequenceId();
      if (LOG.isTraceEnabled()) {
        LOG.trace(Bytes.toString(encodedRegionName) + ", family=" + Bytes.toString(family) +
          ", existingValue=" + existingValue + ", completeSequenceId=" + l);
      }
      // Don't let smaller sequence ids override greater sequence ids.
      if (existingValue == null || (l != HConstants.NO_SEQNUM && l > existingValue.longValue())) {
        storeFlushedSequenceId.put(family, l);
      }
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:41,代码来源:ServerManager.java


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