Java Code Examples for java.util.concurrent.ConcurrentSkipListMap#remove()

The following examples show how to use java.util.concurrent.ConcurrentSkipListMap#remove() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConcurrentSkipListMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source File: ConcurrentSkipListMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: ConcurrentSkipListMapTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 4
Source File: ConcurrentSkipListMapTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 5
Source File: ConcurrentSkipListMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * remove removes the correct key-value pair from the map
 */
public void testRemove() {
    ConcurrentSkipListMap map = map5();
    map.remove(five);
    assertEquals(4, map.size());
    assertFalse(map.containsKey(five));
}
 
Example 6
Source File: ConcurrentSkipListMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * remove(key,value) removes only if pair present
 */
public void testRemove2() {
    ConcurrentSkipListMap map = map5();
    assertTrue(map.containsKey(five));
    assertEquals("E", map.get(five));
    map.remove(five, "E");
    assertEquals(4, map.size());
    assertFalse(map.containsKey(five));
    map.remove(four, "A");
    assertEquals(4, map.size());
    assertTrue(map.containsKey(four));
}
 
Example 7
Source File: ConcurrentSkipListMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * remove(null) throws NPE
 */
public void testRemove1_NullPointerException() {
    ConcurrentSkipListMap c = new ConcurrentSkipListMap();
    c.put("sadsdf", "asdads");
    try {
        c.remove(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
Example 8
Source File: ConcurrentSkipListMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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) {}
}
 
Example 9
Source File: ConcurrentSkipListMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * remove removes the correct key-value pair from the map
 */
public void testRemove() {
    ConcurrentSkipListMap map = map5();
    map.remove(five);
    assertEquals(4, map.size());
    assertFalse(map.containsKey(five));
}
 
Example 10
Source File: ConcurrentSkipListMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * remove(key,value) removes only if pair present
 */
public void testRemove2() {
    ConcurrentSkipListMap map = map5();
    assertTrue(map.containsKey(five));
    assertEquals("E", map.get(five));
    map.remove(five, "E");
    assertEquals(4, map.size());
    assertFalse(map.containsKey(five));
    map.remove(four, "A");
    assertEquals(4, map.size());
    assertTrue(map.containsKey(four));
}
 
Example 11
Source File: ConcurrentSkipListMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * remove(null) throws NPE
 */
public void testRemove1_NullPointerException() {
    ConcurrentSkipListMap c = new ConcurrentSkipListMap();
    c.put("sadsdf", "asdads");
    try {
        c.remove(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
Example 12
Source File: ConcurrentSkipListMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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) {}
}