use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSetTest method testSize.
/**
* size changes when elements added and removed
*/
public void testSize() {
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 ConcurrentSkipListSetTest method testRemoveAll.
/**
* removeAll(c) removes only those elements of c and reports true if changed
*/
public void testRemoveAll() {
for (int i = 1; i < SIZE; ++i) {
NavigableSet q = populatedSet(SIZE);
NavigableSet p = populatedSet(i);
assertTrue(q.removeAll(p));
assertEquals(SIZE - i, q.size());
for (int j = 0; j < i; ++j) {
Integer x = (Integer) (p.pollFirst());
assertFalse(q.contains(x));
}
}
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSetTest method testPollFirst.
/**
* pollFirst succeeds unless empty
*/
public void testPollFirst() {
NavigableSet q = populatedSet(SIZE);
for (int i = 0; i < SIZE; ++i) {
assertEquals(i, q.pollFirst());
}
assertNull(q.pollFirst());
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSetTest method testRemoveElement.
/**
* remove(x) removes x and returns true if present
*/
public void testRemoveElement() {
NavigableSet q = populatedSet(SIZE);
for (int i = 1; i < SIZE; i += 2) {
assertTrue(q.contains(i));
assertTrue(q.remove(i));
assertFalse(q.contains(i));
assertTrue(q.contains(i - 1));
}
for (int i = 0; i < SIZE; i += 2) {
assertTrue(q.contains(i));
assertTrue(q.remove(i));
assertFalse(q.contains(i));
assertFalse(q.remove(i + 1));
assertFalse(q.contains(i + 1));
}
assertTrue(q.isEmpty());
}
use of java.util.NavigableSet in project mapdb by jankotek.
the class ConcurrentSkipListSetTest method testClear.
/**
* clear removes all elements
*/
public void testClear() {
NavigableSet q = populatedSet(SIZE);
q.clear();
assertTrue(q.isEmpty());
assertEquals(0, q.size());
q.add(new Integer(1));
assertFalse(q.isEmpty());
q.clear();
assertTrue(q.isEmpty());
}
Aggregations