Search in sources :

Example 31 with ConcurrentNavigableMap

use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.

the class ConcurrentSkipListMapTest method testKeySetDescendingIteratorOrder.

/**
     * descending iterator of key set is inverse ordered
     */
@Test
public void testKeySetDescendingIteratorOrder() {
    ConcurrentNavigableMap map = map5();
    NavigableSet s = map.navigableKeySet();
    Iterator i = s.descendingIterator();
    Integer last = (Integer) i.next();
    assertEquals(last, five);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer) i.next();
        assertTrue(last.compareTo(k) > 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 32 with ConcurrentNavigableMap

use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.

the class ConcurrentSkipListMapTest method testReplace2.

/**
     * replace succeeds if the key is already present
     */
@Test
public void testReplace2() {
    ConcurrentNavigableMap map = map5();
    assertNotNull(map.replace(one, "Z"));
    assertEquals("Z", map.get(one));
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 33 with ConcurrentNavigableMap

use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.

the class ConcurrentSkipListMapTest method testRemove2.

/**
     * remove(key,value) removes only if pair present
     */
@Test
public void testRemove2() {
    ConcurrentNavigableMap 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));
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 34 with ConcurrentNavigableMap

use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.

the class ConcurrentSkipListMapTest method testReplace.

/**
     * replace fails when the given key is not present
     */
@Test
public void testReplace() {
    ConcurrentNavigableMap map = map5();
    assertNull(map.replace(six, "Z"));
    assertFalse(map.containsKey(six));
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 35 with ConcurrentNavigableMap

use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.

the class ConcurrentSkipListMapTest method testCeilingEntry.

/**
     * ceilingEntry returns next entry.
     */
@Test
public void testCeilingEntry() {
    ConcurrentNavigableMap map = map5();
    Map.Entry e1 = map.ceilingEntry(three);
    assertEquals(three, e1.getKey());
    Map.Entry e2 = map.ceilingEntry(zero);
    assertEquals(one, e2.getKey());
    Map.Entry e3 = map.ceilingEntry(five);
    assertEquals(five, e3.getKey());
    Map.Entry e4 = map.ceilingEntry(six);
    assertNull(e4);
}
Also used : ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Aggregations

ConcurrentNavigableMap (java.util.concurrent.ConcurrentNavigableMap)156 Test (org.junit.Test)147 SortedMap (java.util.SortedMap)25 Map (java.util.Map)19 NavigableMap (java.util.NavigableMap)19 Iterator (java.util.Iterator)12 Set (java.util.Set)10 Collection (java.util.Collection)4 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)4 Update (co.cask.cdap.data2.dataset2.lib.table.Update)3 ArrayList (java.util.ArrayList)2 IncrementValue (co.cask.cdap.data2.dataset2.lib.table.IncrementValue)1 PutValue (co.cask.cdap.data2.dataset2.lib.table.PutValue)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 HashMap (java.util.HashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1