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


Java ConcurrentSkipListMap.put方法代码示例

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


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

示例1: testPollFirstEntry

import java.util.concurrent.ConcurrentSkipListMap; //导入方法依赖的package包/类
/**
 * pollFirstEntry returns entries in order
 */
public void testPollFirstEntry() {
    ConcurrentSkipListMap 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,代码来源:ConcurrentSkipListMapTest.java

示例2: testPollLastEntry

import java.util.concurrent.ConcurrentSkipListMap; //导入方法依赖的package包/类
/**
 * pollLastEntry returns entries in order
 */
public void testPollLastEntry() {
    ConcurrentSkipListMap 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,代码来源:ConcurrentSkipListMapTest.java

示例3: addProperty

import java.util.concurrent.ConcurrentSkipListMap; //导入方法依赖的package包/类
public synchronized void addProperty(Property property) {
    ConcurrentSkipListMap<String, ConcurrentSkipListSet<Property>> propertiesByKey = propertiesByNameAndKey.get(property.getName());
    if (propertiesByKey == null) {
        propertiesByKey = new ConcurrentSkipListMap<>();
        this.propertiesByNameAndKey.put(property.getName(), propertiesByKey);
    }
    ConcurrentSkipListSet<Property> properties = propertiesByKey.get(property.getKey());
    if (properties == null) {
        properties = new ConcurrentSkipListSet<>();
        propertiesByKey.put(property.getKey(), properties);
    }
    properties.add(property);
    this.propertiesList.add(property);
}
 
开发者ID:mware-solutions,项目名称:memory-graph,代码行数:15,代码来源:PropertyCollection.java

示例4: map5

import java.util.concurrent.ConcurrentSkipListMap; //导入方法依赖的package包/类
/**
 * Returns a new map from Integers 1-5 to Strings "A"-"E".
 */
private static ConcurrentSkipListMap map5() {
    ConcurrentSkipListMap map = new ConcurrentSkipListMap();
    assertTrue(map.isEmpty());
    map.put(one, "A");
    map.put(five, "E");
    map.put(three, "C");
    map.put(two, "B");
    map.put(four, "D");
    assertFalse(map.isEmpty());
    assertEquals(5, map.size());
    return map;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:ConcurrentSkipListMapTest.java

示例5: testPut1_NullPointerException

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

示例6: testRemove1_NullPointerException

import java.util.concurrent.ConcurrentSkipListMap; //导入方法依赖的package包/类
/**
 * remove(null) throws NPE
 */
public void testRemove1_NullPointerException() {
    ConcurrentSkipListMap c = new ConcurrentSkipListMap();
    c.put("sadsdf", "asdads");
    try {
        c.remove(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:ConcurrentSkipListMapTest.java

示例7: testRemove2_NullPointerException

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

示例8: map5

import java.util.concurrent.ConcurrentSkipListMap; //导入方法依赖的package包/类
/**
 * Returns a new map from Integers 1-5 to Strings "A"-"E".
 */
private static ConcurrentNavigableMap map5() {
    ConcurrentSkipListMap map = new ConcurrentSkipListMap();
    assertTrue(map.isEmpty());
    map.put(zero, "Z");
    map.put(one, "A");
    map.put(five, "E");
    map.put(three, "C");
    map.put(two, "B");
    map.put(four, "D");
    map.put(seven, "F");
    assertFalse(map.isEmpty());
    assertEquals(7, map.size());
    return map.subMap(one, true, seven, false);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:ConcurrentSkipListSubMapTest.java

示例9: dmap5

import java.util.concurrent.ConcurrentSkipListMap; //导入方法依赖的package包/类
/**
 * Returns a new map from Integers -5 to -1 to Strings "A"-"E".
 */
private static ConcurrentNavigableMap dmap5() {
    ConcurrentSkipListMap map = new ConcurrentSkipListMap();
    assertTrue(map.isEmpty());
    map.put(m1, "A");
    map.put(m5, "E");
    map.put(m3, "C");
    map.put(m2, "B");
    map.put(m4, "D");
    assertFalse(map.isEmpty());
    assertEquals(5, map.size());
    return map.descendingMap();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:ConcurrentSkipListSubMapTest.java

示例10: testRemove3

import java.util.concurrent.ConcurrentSkipListMap; //导入方法依赖的package包/类
/**
 * remove(x, null) returns false
 */
public void testRemove3() {
    ConcurrentSkipListMap c = new ConcurrentSkipListMap();
    c.put("sadsdf", "asdads");
    assertFalse(c.remove("sadsdf", null));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:ConcurrentSkipListMapTest.java


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