use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testDescendingFloor.
/**
* floor returns preceding element
*/
public void testDescendingFloor() {
NavigableSet q = dset5();
Object e1 = q.floor(m3);
assertEquals(m3, e1);
Object e2 = q.floor(m6);
assertEquals(m5, e2);
Object e3 = q.floor(m1);
assertEquals(m1, e3);
Object e4 = q.floor(zero);
assertNull(e4);
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testDescendingIteratorRemove.
/**
* iterator.remove removes current element
*/
public void testDescendingIteratorRemove() {
final NavigableSet q = dset0();
q.add(new Integer(2));
q.add(new Integer(1));
q.add(new Integer(3));
Iterator it = q.iterator();
it.next();
it.remove();
it = q.iterator();
assertEquals(it.next(), new Integer(2));
assertEquals(it.next(), new Integer(3));
assertFalse(it.hasNext());
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testCeiling.
/**
* ceiling returns next element
*/
public void testCeiling() {
NavigableSet q = set5();
Object e1 = q.ceiling(three);
assertEquals(three, e1);
Object e2 = q.ceiling(zero);
assertEquals(one, e2);
Object e3 = q.ceiling(five);
assertEquals(five, e3);
Object e4 = q.ceiling(six);
assertNull(e4);
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testAddDup.
/**
* Add of duplicate element fails
*/
public void testAddDup() {
NavigableSet q = set0();
assertTrue(q.add(six));
assertFalse(q.add(six));
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testHeadSetContents.
/**
* headSet returns set with keys in requested range
*/
public void testHeadSetContents() {
NavigableSet set = set5();
SortedSet sm = set.headSet(four);
assertTrue(sm.contains(one));
assertTrue(sm.contains(two));
assertTrue(sm.contains(three));
assertFalse(sm.contains(four));
assertFalse(sm.contains(five));
Iterator i = sm.iterator();
Object k;
k = (Integer) (i.next());
assertEquals(one, k);
k = (Integer) (i.next());
assertEquals(two, k);
k = (Integer) (i.next());
assertEquals(three, k);
assertFalse(i.hasNext());
sm.clear();
assertTrue(sm.isEmpty());
assertEquals(2, set.size());
assertEquals(four, set.first());
}
Aggregations