Search in sources :

Example 71 with NavigableSet

use of java.util.NavigableSet in project mapdb by jankotek.

the class TreeSubSetTest 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());
}
Also used : NavigableSet(java.util.NavigableSet) Iterator(java.util.Iterator) SortedSet(java.util.SortedSet)

Example 72 with NavigableSet

use of java.util.NavigableSet in project mapdb by jankotek.

the class TreeSubSetTest method testAdd.

/**
     * Add of comparable element succeeds
     */
public void testAdd() {
    NavigableSet q = set0();
    assertTrue(q.add(six));
}
Also used : NavigableSet(java.util.NavigableSet)

Example 73 with NavigableSet

use of java.util.NavigableSet in project mapdb by jankotek.

the class TreeSubSetTest method testContains.

/**
     * contains(x) reports true when elements added but not yet removed
     */
public void testContains() {
    NavigableSet q = populatedSet(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(q.contains(new Integer(i)));
        q.pollFirst();
        assertFalse(q.contains(new Integer(i)));
    }
}
Also used : NavigableSet(java.util.NavigableSet)

Example 74 with NavigableSet

use of java.util.NavigableSet in project mapdb by jankotek.

the class TreeSubSetTest method testSerialization.

/**
     * A deserialized serialized set has same elements
     */
public void testSerialization() throws Exception {
    NavigableSet x = populatedSet(SIZE);
    NavigableSet y = serialClone(x);
    assertNotSame(x, y);
    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());
}
Also used : NavigableSet(java.util.NavigableSet)

Example 75 with NavigableSet

use of java.util.NavigableSet in project mapdb by jankotek.

the class TreeSubSetTest method testClear.

/**
     * clear removes all elements
     */
public void testClear() {
    NavigableSet q = populatedSet(SIZE);
    q.clear();
    assertTrue(q.isEmpty());
    assertEquals(0, q.size());
    assertTrue(q.add(new Integer(1)));
    assertFalse(q.isEmpty());
    q.clear();
    assertTrue(q.isEmpty());
}
Also used : NavigableSet(java.util.NavigableSet)

Aggregations

NavigableSet (java.util.NavigableSet)197 Iterator (java.util.Iterator)36 SortedSet (java.util.SortedSet)26 Map (java.util.Map)12 TreeSet (java.util.TreeSet)11 HashMap (java.util.HashMap)7 Set (java.util.Set)6 TimeRange (org.apache.hadoop.hbase.io.TimeRange)6 List (java.util.List)5 TestSuite (junit.framework.TestSuite)5 Scan (org.apache.hadoop.hbase.client.Scan)5 Test (org.testng.annotations.Test)5 ArrayList (java.util.ArrayList)4 TreeMap (java.util.TreeMap)4 HashSet (java.util.HashSet)3 Get (org.apache.hadoop.hbase.client.Get)3 GwtIncompatible (com.google.common.annotations.GwtIncompatible)2 TestStringSetGenerator (com.google.common.collect.testing.TestStringSetGenerator)2 TestStringSortedSetGenerator (com.google.common.collect.testing.TestStringSortedSetGenerator)2 ByteString (com.google.protobuf.ByteString)2