use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListSubMapTest method testDescendingRemove2.
/**
* remove(key,value) removes only if pair present
*/
@Test
public void testDescendingRemove2() {
if (isReadOnly())
return;
ConcurrentNavigableMap map = dmap5();
assertTrue(map.containsKey(m5));
assertEquals("E", map.get(m5));
map.remove(m5, "E");
assertEquals(4, map.size());
assertFalse(map.containsKey(m5));
map.remove(m4, "A");
assertEquals(4, map.size());
assertTrue(map.containsKey(m4));
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testTailMapContents.
/**
* tailMap returns map with keys in requested range
*/
@Test
public void testTailMapContents() {
ConcurrentNavigableMap map = map5();
NavigableMap sm = map.tailMap(two, true);
assertFalse(sm.containsKey(one));
assertTrue(sm.containsKey(two));
assertTrue(sm.containsKey(three));
assertTrue(sm.containsKey(four));
assertTrue(sm.containsKey(five));
Iterator i = sm.keySet().iterator();
Object k;
k = (Integer) (i.next());
assertEquals(two, k);
k = (Integer) (i.next());
assertEquals(three, k);
k = (Integer) (i.next());
assertEquals(four, k);
k = (Integer) (i.next());
assertEquals(five, k);
assertFalse(i.hasNext());
Iterator r = sm.descendingKeySet().iterator();
k = (Integer) (r.next());
assertEquals(five, k);
k = (Integer) (r.next());
assertEquals(four, k);
k = (Integer) (r.next());
assertEquals(three, k);
k = (Integer) (r.next());
assertEquals(two, k);
assertFalse(r.hasNext());
Iterator ei = sm.entrySet().iterator();
Map.Entry e;
e = (Map.Entry) (ei.next());
assertEquals(two, e.getKey());
assertEquals("B", e.getValue());
e = (Map.Entry) (ei.next());
assertEquals(three, e.getKey());
assertEquals("C", e.getValue());
e = (Map.Entry) (ei.next());
assertEquals(four, e.getKey());
assertEquals("D", e.getValue());
e = (Map.Entry) (ei.next());
assertEquals(five, e.getKey());
assertEquals("E", e.getValue());
assertFalse(i.hasNext());
NavigableMap ssm = sm.tailMap(four, true);
assertEquals(four, ssm.firstKey());
assertEquals(five, ssm.lastKey());
if (isReadOnly())
return;
assertEquals("D", ssm.remove(four));
assertEquals(1, ssm.size());
assertEquals(3, sm.size());
assertEquals(4, map.size());
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testCeilingKey.
/**
* ceilingKey returns next element
*/
@Test
public void testCeilingKey() {
ConcurrentNavigableMap q = map5();
Object e1 = q.ceilingKey(three);
assertEquals(three, e1);
Object e2 = q.ceilingKey(zero);
assertEquals(one, e2);
Object e3 = q.ceilingKey(five);
assertEquals(five, e3);
Object e4 = q.ceilingKey(six);
assertNull(e4);
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testPutIfAbsent.
/**
* putIfAbsent works when the given key is not present
*/
@Test
public void testPutIfAbsent() {
ConcurrentNavigableMap map = map5();
map.putIfAbsent(six, "Z");
assertTrue(map.containsKey(six));
}
use of java.util.concurrent.ConcurrentNavigableMap in project mapdb by jankotek.
the class ConcurrentSkipListMapTest method testLastKey.
/**
* lastKey returns last key
*/
@Test
public void testLastKey() {
ConcurrentNavigableMap map = map5();
assertEquals(five, map.lastKey());
}
Aggregations