use of java.util.NavigableSet in project mapdb by jankotek.
the class TreeMapTest method testDescendingKeySetDescendingIteratorOrder.
/**
* descending iterator of descendingKeySet is ordered
*/
public void testDescendingKeySetDescendingIteratorOrder() {
TreeMap map = map5();
NavigableSet s = map.descendingKeySet();
Iterator i = s.descendingIterator();
Integer last = (Integer) i.next();
assertEquals(last, one);
int count = 1;
while (i.hasNext()) {
Integer k = (Integer) i.next();
assertTrue(last.compareTo(k) < 0);
last = k;
++count;
}
assertEquals(5, count);
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class TreeMapTest method testKeySetDescendingIteratorOrder.
/**
* descending iterator of key set is inverse ordered
*/
public void testKeySetDescendingIteratorOrder() {
TreeMap 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);
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class TreeSubSetTest method testRetainAll.
/**
* retainAll(c) retains only those elements of c and reports true if changed
*/
public void testRetainAll() {
NavigableSet q = populatedSet(SIZE);
NavigableSet p = populatedSet(SIZE);
for (int i = 0; i < SIZE; ++i) {
boolean changed = q.retainAll(p);
if (i == 0)
assertFalse(changed);
else
assertTrue(changed);
assertTrue(q.containsAll(p));
assertEquals(SIZE - i, q.size());
p.pollFirst();
}
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class TreeSubSetTest method testDescendingSize.
/**
* size changes when elements added and removed
*/
public void testDescendingSize() {
NavigableSet q = populatedSet(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(SIZE - i, q.size());
q.pollFirst();
}
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.size());
q.add(new Integer(i));
}
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class TreeSubSetTest 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());
}
Aggregations