use of java.util.SortedSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testSubSetContents.
//
// /**
// * A deserialized serialized set has same elements
// */
// TODO treeSet serialization
// public void testSerialization() throws Exception {
// NavigableSet x = populatedSet(SIZE);
// 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());
// }
/**
* subSet returns set with keys in requested range
*/
public void testSubSetContents() {
NavigableSet set = set5();
SortedSet sm = set.subSet(two, four);
assertEquals(two, sm.first());
assertEquals(three, sm.last());
assertEquals(2, sm.size());
assertFalse(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(two, k);
k = (Integer) (i.next());
assertEquals(three, k);
assertFalse(i.hasNext());
Iterator j = sm.iterator();
j.next();
j.remove();
assertFalse(set.contains(two));
assertEquals(4, set.size());
assertEquals(1, sm.size());
assertEquals(three, sm.first());
assertEquals(three, sm.last());
assertTrue(sm.remove(three));
assertTrue(sm.isEmpty());
assertEquals(3, set.size());
}
use of java.util.SortedSet 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.SortedSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testDescendingSubSetContents.
/**
* subSet returns set with keys in requested range
*/
public void testDescendingSubSetContents() {
NavigableSet set = dset5();
SortedSet sm = set.subSet(m2, m4);
assertEquals(m2, sm.first());
assertEquals(m3, sm.last());
assertEquals(2, sm.size());
assertFalse(sm.contains(m1));
assertTrue(sm.contains(m2));
assertTrue(sm.contains(m3));
assertFalse(sm.contains(m4));
assertFalse(sm.contains(m5));
Iterator i = sm.iterator();
Object k;
k = (Integer) (i.next());
assertEquals(m2, k);
k = (Integer) (i.next());
assertEquals(m3, k);
assertFalse(i.hasNext());
Iterator j = sm.iterator();
j.next();
j.remove();
assertFalse(set.contains(m2));
assertEquals(4, set.size());
assertEquals(1, sm.size());
assertEquals(m3, sm.first());
assertEquals(m3, sm.last());
assertTrue(sm.remove(m3));
assertTrue(sm.isEmpty());
assertEquals(3, set.size());
}
use of java.util.SortedSet in project mapdb by jankotek.
the class ConcurrentSkipListSubSetTest method testDescendingSubSetContents2.
public void testDescendingSubSetContents2() {
NavigableSet set = dset5();
SortedSet sm = set.subSet(m2, m3);
assertEquals(1, sm.size());
assertEquals(m2, sm.first());
assertEquals(m2, sm.last());
assertFalse(sm.contains(m1));
assertTrue(sm.contains(m2));
assertFalse(sm.contains(m3));
assertFalse(sm.contains(m4));
assertFalse(sm.contains(m5));
Iterator i = sm.iterator();
Object k;
k = (Integer) (i.next());
assertEquals(m2, k);
assertFalse(i.hasNext());
Iterator j = sm.iterator();
j.next();
j.remove();
assertFalse(set.contains(m2));
assertEquals(4, set.size());
assertEquals(0, sm.size());
assertTrue(sm.isEmpty());
assertFalse(sm.remove(m3));
assertEquals(4, set.size());
}
use of java.util.SortedSet in project mapdb by jankotek.
the class TreeSetTest method testTailSetContents.
/**
* tailSet returns set with keys in requested range
*/
public void testTailSetContents() {
TreeSet 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());
}
Aggregations