Search in sources :

Example 51 with TreeMap

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

the class TreeMapTest method testHeadMapContents.

/**
     * headMap returns map with keys in requested range
     */
public void testHeadMapContents() {
    TreeMap map = map5();
    NavigableMap sm = map.headMap(four, false);
    assertTrue(sm.containsKey(one));
    assertTrue(sm.containsKey(two));
    assertTrue(sm.containsKey(three));
    assertFalse(sm.containsKey(four));
    assertFalse(sm.containsKey(five));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer) (i.next());
    assertEquals(one, k);
    k = (Integer) (i.next());
    assertEquals(two, k);
    k = (Integer) (i.next());
    assertEquals(three, k);
    assertFalse(i.hasNext());
    sm.clear();
    assertTrue(sm.isEmpty());
    assertEquals(2, map.size());
    assertEquals(four, map.firstKey());
}
Also used : NavigableMap(java.util.NavigableMap) Iterator(java.util.Iterator) TreeMap(java.util.TreeMap)

Example 52 with TreeMap

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

the class TreeMapTest method testContainsValue.

/**
     * containsValue returns true for held values
     */
public void testContainsValue() {
    TreeMap map = map5();
    assertTrue(map.containsValue("A"));
    assertFalse(map.containsValue("Z"));
}
Also used : TreeMap(java.util.TreeMap)

Example 53 with TreeMap

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

the class TreeMapTest method testHigherKey.

/**
     * higherKey returns next element
     */
public void testHigherKey() {
    TreeMap q = map5();
    Object e1 = q.higherKey(three);
    assertEquals(four, e1);
    Object e2 = q.higherKey(zero);
    assertEquals(one, e2);
    Object e3 = q.higherKey(five);
    assertNull(e3);
    Object e4 = q.higherKey(six);
    assertNull(e4);
}
Also used : TreeMap(java.util.TreeMap)

Example 54 with TreeMap

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

the class TreeMapTest method testLowerEntry.

/**
     * lowerEntry returns preceding entry.
     */
public void testLowerEntry() {
    TreeMap map = map5();
    Map.Entry e1 = map.lowerEntry(three);
    assertEquals(two, e1.getKey());
    Map.Entry e2 = map.lowerEntry(six);
    assertEquals(five, e2.getKey());
    Map.Entry e3 = map.lowerEntry(one);
    assertNull(e3);
    Map.Entry e4 = map.lowerEntry(zero);
    assertNull(e4);
}
Also used : TreeMap(java.util.TreeMap) NavigableMap(java.util.NavigableMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 55 with TreeMap

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

the class TreeMapTest method testPutAll.

/**
     * putAll adds all key-value pairs from the given map
     */
public void testPutAll() {
    TreeMap empty = new TreeMap();
    TreeMap map = map5();
    empty.putAll(map);
    assertEquals(5, empty.size());
    assertTrue(empty.containsKey(one));
    assertTrue(empty.containsKey(two));
    assertTrue(empty.containsKey(three));
    assertTrue(empty.containsKey(four));
    assertTrue(empty.containsKey(five));
}
Also used : TreeMap(java.util.TreeMap)

Aggregations

TreeMap (java.util.TreeMap)4400 Map (java.util.Map)1245 ArrayList (java.util.ArrayList)930 HashMap (java.util.HashMap)871 Test (org.junit.Test)614 List (java.util.List)542 Before (org.junit.Before)505 IOException (java.io.IOException)402 HashSet (java.util.HashSet)301 Set (java.util.Set)268 File (java.io.File)267 SortedMap (java.util.SortedMap)240 TreeSet (java.util.TreeSet)213 LinkedHashMap (java.util.LinkedHashMap)196 Key (org.apache.accumulo.core.data.Key)156 Value (org.apache.accumulo.core.data.Value)156 Iterator (java.util.Iterator)149 NavigableMap (java.util.NavigableMap)124 Collection (java.util.Collection)115 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)111