Search in sources :

Example 11 with NavigableSet

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

the class ConcurrentSkipListSetTest method testSize.

/**
     * size changes when elements added and removed
     */
public void testSize() {
    NavigableSet q = populatedSet(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(SIZE - i, q.size());
        q.pollFirst();
    }
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.size());
        q.add(new Integer(i));
    }
}
Also used : NavigableSet(java.util.NavigableSet)

Example 12 with NavigableSet

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

the class ConcurrentSkipListSetTest method testRemoveAll.

/**
     * removeAll(c) removes only those elements of c and reports true if changed
     */
public void testRemoveAll() {
    for (int i = 1; i < SIZE; ++i) {
        NavigableSet q = populatedSet(SIZE);
        NavigableSet p = populatedSet(i);
        assertTrue(q.removeAll(p));
        assertEquals(SIZE - i, q.size());
        for (int j = 0; j < i; ++j) {
            Integer x = (Integer) (p.pollFirst());
            assertFalse(q.contains(x));
        }
    }
}
Also used : NavigableSet(java.util.NavigableSet)

Example 13 with NavigableSet

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

the class ConcurrentSkipListSetTest method testPollFirst.

/**
     * pollFirst succeeds unless empty
     */
public void testPollFirst() {
    NavigableSet q = populatedSet(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.pollFirst());
    }
    assertNull(q.pollFirst());
}
Also used : NavigableSet(java.util.NavigableSet)

Example 14 with NavigableSet

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

the class ConcurrentSkipListSetTest 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 15 with NavigableSet

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

the class ConcurrentSkipListSetTest method testClear.

/**
     * clear removes all elements
     */
public void testClear() {
    NavigableSet q = populatedSet(SIZE);
    q.clear();
    assertTrue(q.isEmpty());
    assertEquals(0, q.size());
    q.add(new Integer(1));
    assertFalse(q.isEmpty());
    q.clear();
    assertTrue(q.isEmpty());
}
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