Search in sources :

Example 66 with NavigableSet

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

the class TreeSubSetTest method testSubSetContents.

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

Example 67 with NavigableSet

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

the class TreeSubSetTest method testDescendingToArray2.

/**
     * toArray(a) contains all elements
     */
public void testDescendingToArray2() {
    NavigableSet q = populatedSet(SIZE);
    Integer[] ints = new Integer[SIZE];
    assertSame(ints, q.toArray(ints));
    Arrays.sort(ints);
    for (int i = 0; i < ints.length; i++) assertEquals(ints[i], q.pollFirst());
}
Also used : NavigableSet(java.util.NavigableSet)

Example 68 with NavigableSet

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

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

Example 69 with NavigableSet

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

the class TreeSubSetTest method testDescendingIteratorRemove.

/**
     * iterator.remove removes current element
     */
public void testDescendingIteratorRemove() {
    final NavigableSet q = dset0();
    q.add(new Integer(2));
    q.add(new Integer(1));
    q.add(new Integer(3));
    Iterator it = q.iterator();
    it.next();
    it.remove();
    it = q.iterator();
    assertEquals(2, it.next());
    assertEquals(3, it.next());
    assertFalse(it.hasNext());
}
Also used : NavigableSet(java.util.NavigableSet) Iterator(java.util.Iterator)

Example 70 with NavigableSet

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

the class TreeSubSetTest 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)

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