use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testDescendingAddAll5.
/**
* Set contains all elements of successful addAll
*/
public void testDescendingAddAll5() {
Integer[] empty = new Integer[0];
Integer[] ints = new Integer[SIZE];
for (int i = 0; i < SIZE; ++i) ints[i] = new Integer(SIZE - 1 - i);
NavigableSet q = dset0();
assertFalse(q.addAll(Arrays.asList(empty)));
assertTrue(q.addAll(Arrays.asList(ints)));
for (int i = 0; i < SIZE; ++i) assertEquals(new Integer(i), q.pollFirst());
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testDescendingRemoveElement.
/**
* remove(x) removes x and returns true if present
*/
public void testDescendingRemoveElement() {
NavigableSet q = populatedSet(SIZE);
for (int i = 1; i < SIZE; i += 2) {
assertTrue(q.remove(new Integer(i)));
}
for (int i = 0; i < SIZE; i += 2) {
assertTrue(q.remove(new Integer(i)));
assertFalse(q.remove(new Integer(i + 1)));
}
assertTrue(q.isEmpty());
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testTailSetContents.
/**
* tailSet returns set with keys in requested range
*/
public void testTailSetContents() {
NavigableSet set = set5();
SortedSet sm = set.tailSet(two);
assertFalse(sm.contains(one));
assertTrue(sm.contains(two));
assertTrue(sm.contains(three));
assertTrue(sm.contains(four));
assertTrue(sm.contains(five));
Iterator i = sm.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());
SortedSet ssm = sm.tailSet(four);
assertEquals(four, ssm.first());
assertEquals(five, ssm.last());
assertTrue(ssm.remove(four));
assertEquals(1, ssm.size());
assertEquals(3, sm.size());
assertEquals(4, set.size());
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testDescendingContainsAll.
/**
* containsAll(c) is true when c contains a subset of elements
*/
public void testDescendingContainsAll() {
NavigableSet q = populatedSet(SIZE);
NavigableSet p = dset0();
for (int i = 0; i < SIZE; ++i) {
assertTrue(q.containsAll(p));
assertFalse(p.containsAll(q));
p.add(new Integer(i));
}
assertTrue(p.containsAll(q));
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testDescendingSerialization.
/**
* A deserialized serialized set has same elements
*/
public void testDescendingSerialization() throws Exception {
NavigableSet x = dset5();
NavigableSet y = serialClone(x);
assertNotSame(y, x);
assertEquals(x.size(), y.size());
assertEquals(x, y);
assertEquals(y, x);
while (!x.isEmpty()) {
assertFalse(y.isEmpty());
assertEquals(x.pollFirst(), y.pollFirst());
}
assertTrue(y.isEmpty());
}
Aggregations