Search in sources :

Example 41 with TreeMap

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

the class TreeMapTest method testDescendingEntrySet.

/**
     * descendingEntrySet contains all pairs
     */
public void testDescendingEntrySet() {
    TreeMap map = map5();
    Set s = map.descendingMap().entrySet();
    assertEquals(5, s.size());
    Iterator it = s.iterator();
    while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        assertTrue((e.getKey().equals(one) && e.getValue().equals("A")) || (e.getKey().equals(two) && e.getValue().equals("B")) || (e.getKey().equals(three) && e.getValue().equals("C")) || (e.getKey().equals(four) && e.getValue().equals("D")) || (e.getKey().equals(five) && e.getValue().equals("E")));
    }
}
Also used : Set(java.util.Set) NavigableSet(java.util.NavigableSet) BitSet(java.util.BitSet) Iterator(java.util.Iterator) TreeMap(java.util.TreeMap) NavigableMap(java.util.NavigableMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 42 with TreeMap

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

the class TreeMapTest method testValues.

/**
     * values collection contains all values
     */
public void testValues() {
    TreeMap map = map5();
    Collection s = map.values();
    assertEquals(5, s.size());
    assertTrue(s.contains("A"));
    assertTrue(s.contains("B"));
    assertTrue(s.contains("C"));
    assertTrue(s.contains("D"));
    assertTrue(s.contains("E"));
}
Also used : Collection(java.util.Collection) TreeMap(java.util.TreeMap)

Example 43 with TreeMap

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

the class TreeMapTest method testKeySet.

/**
     * keySet returns a Set containing all the keys
     */
public void testKeySet() {
    TreeMap map = map5();
    Set s = map.keySet();
    assertEquals(5, s.size());
    assertTrue(s.contains(one));
    assertTrue(s.contains(two));
    assertTrue(s.contains(three));
    assertTrue(s.contains(four));
    assertTrue(s.contains(five));
}
Also used : Set(java.util.Set) NavigableSet(java.util.NavigableSet) BitSet(java.util.BitSet) TreeMap(java.util.TreeMap)

Example 44 with TreeMap

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

the class TreeMapTest method testGet_NullPointerException.

// Exception tests
/**
     * get(null) of nonempty map throws NPE
     */
public void testGet_NullPointerException() {
    TreeMap c = map5();
    try {
        c.get(null);
        shouldThrow();
    } catch (NullPointerException success) {
    }
}
Also used : TreeMap(java.util.TreeMap)

Example 45 with TreeMap

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

the class TreeMapTest method testKeySetDescendingIteratorOrder.

/**
     * descending iterator of key set is inverse ordered
     */
public void testKeySetDescendingIteratorOrder() {
    TreeMap map = map5();
    NavigableSet s = map.navigableKeySet();
    Iterator i = s.descendingIterator();
    Integer last = (Integer) i.next();
    assertEquals(last, five);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer) i.next();
        assertTrue(last.compareTo(k) > 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
Also used : NavigableSet(java.util.NavigableSet) Iterator(java.util.Iterator) TreeMap(java.util.TreeMap)

Aggregations

TreeMap (java.util.TreeMap)4328 Map (java.util.Map)1215 ArrayList (java.util.ArrayList)908 HashMap (java.util.HashMap)848 Test (org.junit.Test)610 List (java.util.List)530 Before (org.junit.Before)504 IOException (java.io.IOException)390 HashSet (java.util.HashSet)292 File (java.io.File)260 Set (java.util.Set)258 SortedMap (java.util.SortedMap)238 TreeSet (java.util.TreeSet)208 LinkedHashMap (java.util.LinkedHashMap)181 Key (org.apache.accumulo.core.data.Key)156 Value (org.apache.accumulo.core.data.Value)156 Iterator (java.util.Iterator)147 NavigableMap (java.util.NavigableMap)124 Collection (java.util.Collection)111 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)110