Search in sources :

Example 16 with NavigableSet

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

the class ConcurrentSkipListSetTest method testRetainAll.

/**
     * retainAll(c) retains only those elements of c and reports true if changed
     */
public void testRetainAll() {
    NavigableSet q = populatedSet(SIZE);
    NavigableSet p = populatedSet(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        boolean changed = q.retainAll(p);
        if (i == 0)
            assertFalse(changed);
        else
            assertTrue(changed);
        assertTrue(q.containsAll(p));
        assertEquals(SIZE - i, q.size());
        p.pollFirst();
    }
}
Also used : NavigableSet(java.util.NavigableSet)

Example 17 with NavigableSet

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

the class ConcurrentSkipListSetTest method testAddAll3.

/**
     * addAll of a collection with any null elements throws NPE after
     * possibly adding some elements
     */
public void testAddAll3() {
    NavigableSet q = emptySet();
    Integer[] ints = new Integer[SIZE];
    for (int i = 0; i < SIZE - 1; ++i) ints[i] = new Integer(i);
    try {
        q.addAll(Arrays.asList(ints));
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : NavigableSet(java.util.NavigableSet)

Example 18 with NavigableSet

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

the class ConcurrentSkipListSetTest method testContainsAll.

/**
     * containsAll(c) is true when c contains a subset of elements
     */
public void testContainsAll() {
    NavigableSet q = populatedSet(SIZE);
    NavigableSet p = emptySet();
    for (int i = 0; i < SIZE; ++i) {
        assertTrue(q.containsAll(p));
        assertFalse(p.containsAll(q));
        p.add(new Integer(i));
    }
    assertTrue(p.containsAll(q));
}
Also used : NavigableSet(java.util.NavigableSet)

Example 19 with NavigableSet

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

the class ConcurrentSkipListSubSetTest method testSubSetContents2.

public void testSubSetContents2() {
    NavigableSet set = set5();
    SortedSet sm = set.subSet(two, three);
    assertEquals(1, sm.size());
    assertEquals(two, sm.first());
    assertEquals(two, sm.last());
    assertFalse(sm.contains(one));
    assertTrue(sm.contains(two));
    assertFalse(sm.contains(three));
    assertFalse(sm.contains(four));
    assertFalse(sm.contains(five));
    Iterator i = sm.iterator();
    Object k;
    k = (Integer) (i.next());
    assertEquals(two, k);
    assertFalse(i.hasNext());
    Iterator j = sm.iterator();
    j.next();
    j.remove();
    assertFalse(set.contains(two));
    assertEquals(4, set.size());
    assertEquals(0, sm.size());
    assertTrue(sm.isEmpty());
    assertFalse(sm.remove(three));
    assertEquals(4, set.size());
}
Also used : NavigableSet(java.util.NavigableSet) Iterator(java.util.Iterator) SortedSet(java.util.SortedSet)

Example 20 with NavigableSet

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

the class ConcurrentSkipListSubSetTest method testDescendingRetainAll.

/**
     * retainAll(c) retains only those elements of c and reports true if changed
     */
public void testDescendingRetainAll() {
    NavigableSet q = populatedSet(SIZE);
    NavigableSet p = populatedSet(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        boolean changed = q.retainAll(p);
        if (i == 0)
            assertFalse(changed);
        else
            assertTrue(changed);
        assertTrue(q.containsAll(p));
        assertEquals(SIZE - i, q.size());
        p.pollFirst();
    }
}
Also used : NavigableSet(java.util.NavigableSet)

Aggregations

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