Search in sources :

Example 36 with TreeSet

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

the class TreeSetTest method testAddNull.

/**
     * add(null) throws NPE if nonempty
     */
public void testAddNull() {
    TreeSet q = populatedSet(SIZE);
    try {
        q.add(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : TreeSet(java.util.TreeSet)

Example 37 with TreeSet

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

the class TreeSetTest method testSubSetContents2.

public void testSubSetContents2() {
    TreeSet 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 : TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) SortedSet(java.util.SortedSet)

Example 38 with TreeSet

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

the class TreeSetTest method testToArray.

/**
     * toArray contains all elements in sorted order
     */
public void testToArray() {
    TreeSet q = populatedSet(SIZE);
    Object[] o = q.toArray();
    for (int i = 0; i < o.length; i++) assertSame(o[i], q.pollFirst());
}
Also used : TreeSet(java.util.TreeSet)

Example 39 with TreeSet

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

the class TreeSetTest method testFloor.

/**
     * floor returns preceding element
     */
public void testFloor() {
    TreeSet q = set5();
    Object e1 = q.floor(three);
    assertEquals(three, e1);
    Object e2 = q.floor(six);
    assertEquals(five, e2);
    Object e3 = q.floor(one);
    assertEquals(one, e3);
    Object e4 = q.floor(zero);
    assertNull(e4);
}
Also used : TreeSet(java.util.TreeSet)

Example 40 with TreeSet

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

the class TreeSetTest method testRetainAll.

/**
     * retainAll(c) retains only those elements of c and reports true if changed
     */
public void testRetainAll() {
    TreeSet q = populatedSet(SIZE);
    TreeSet 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 : TreeSet(java.util.TreeSet)

Aggregations

TreeSet (java.util.TreeSet)3795 ArrayList (java.util.ArrayList)835 Test (org.junit.Test)544 HashMap (java.util.HashMap)502 HashSet (java.util.HashSet)430 Set (java.util.Set)424 Map (java.util.Map)405 IOException (java.io.IOException)378 File (java.io.File)341 List (java.util.List)323 TreeMap (java.util.TreeMap)229 Iterator (java.util.Iterator)189 SortedSet (java.util.SortedSet)186 LinkedList (java.util.LinkedList)110 LinkedHashSet (java.util.LinkedHashSet)106 Date (java.util.Date)94 Collection (java.util.Collection)92 Comparator (java.util.Comparator)85 Test (org.testng.annotations.Test)81 Text (org.apache.hadoop.io.Text)79