Search in sources :

Example 51 with NavigableSet

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

the class ConcurrentSkipListSubSetTest method set5.

/**
     * Returns a new set of first 5 ints.
     */
private NavigableSet set5() {
    ConcurrentSkipListSet q = new ConcurrentSkipListSet();
    assertTrue(q.isEmpty());
    q.add(one);
    q.add(two);
    q.add(three);
    q.add(four);
    q.add(five);
    q.add(zero);
    q.add(seven);
    NavigableSet s = q.subSet(one, true, seven, false);
    assertEquals(5, s.size());
    return s;
}
Also used : NavigableSet(java.util.NavigableSet) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet)

Example 52 with NavigableSet

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

Example 53 with NavigableSet

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

the class ConcurrentSkipListSubSetTest method testDescendingCeiling.

/**
     * ceiling returns next element
     */
public void testDescendingCeiling() {
    NavigableSet q = dset5();
    Object e1 = q.ceiling(m3);
    assertEquals(m3, e1);
    Object e2 = q.ceiling(zero);
    assertEquals(m1, e2);
    Object e3 = q.ceiling(m5);
    assertEquals(m5, e3);
    Object e4 = q.ceiling(m6);
    assertNull(e4);
}
Also used : NavigableSet(java.util.NavigableSet)

Example 54 with NavigableSet

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

the class ConcurrentSkipListSubSetTest method testAddNull.

/**
     * add(null) throws NPE
     */
public void testAddNull() {
    NavigableSet q = set0();
    try {
        q.add(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : NavigableSet(java.util.NavigableSet)

Example 55 with NavigableSet

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

the class ConcurrentSkipListSubSetTest method testIterator.

/**
     * iterator iterates through all elements
     */
public void testIterator() {
    NavigableSet q = populatedSet(SIZE);
    Iterator it = q.iterator();
    int i;
    for (i = 0; it.hasNext(); i++) assertTrue(q.contains(it.next()));
    assertEquals(i, SIZE);
    assertIteratorExhausted(it);
}
Also used : NavigableSet(java.util.NavigableSet) Iterator(java.util.Iterator)

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