Search in sources :

Example 36 with NavigableMap

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

the class TreeSubMapTest method testDescendingSubMapContents.

/**
     * subMap returns map with keys in requested range
     */
public void testDescendingSubMapContents() {
    NavigableMap map = dmap5();
    SortedMap sm = map.subMap(m2, m4);
    assertEquals(m2, sm.firstKey());
    assertEquals(m3, sm.lastKey());
    assertEquals(2, sm.size());
    assertFalse(sm.containsKey(m1));
    assertTrue(sm.containsKey(m2));
    assertTrue(sm.containsKey(m3));
    assertFalse(sm.containsKey(m4));
    assertFalse(sm.containsKey(m5));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer) (i.next());
    assertEquals(m2, k);
    k = (Integer) (i.next());
    assertEquals(m3, k);
    assertFalse(i.hasNext());
    Iterator j = sm.keySet().iterator();
    j.next();
    j.remove();
    assertFalse(map.containsKey(m2));
    assertEquals(4, map.size());
    assertEquals(1, sm.size());
    assertEquals(m3, sm.firstKey());
    assertEquals(m3, sm.lastKey());
    assertEquals("C", sm.remove(m3));
    assertTrue(sm.isEmpty());
    assertEquals(3, map.size());
}
Also used : NavigableMap(java.util.NavigableMap) SortedMap(java.util.SortedMap) Iterator(java.util.Iterator)

Example 37 with NavigableMap

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

the class TreeSubMapTest method testDescendingEquals.

/**
     * Maps with same contents are equal
     */
public void testDescendingEquals() {
    NavigableMap map1 = dmap5();
    NavigableMap map2 = dmap5();
    assertEquals(map1, map2);
    assertEquals(map2, map1);
    map1.clear();
    assertFalse(map1.equals(map2));
    assertFalse(map2.equals(map1));
}
Also used : NavigableMap(java.util.NavigableMap)

Example 38 with NavigableMap

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

the class TreeSubMapTest method testEntrySet.

/**
     * entrySet contains all pairs
     */
public void testEntrySet() {
    NavigableMap map = map5();
    Set s = map.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) NavigableMap(java.util.NavigableMap) Iterator(java.util.Iterator) TreeMap(java.util.TreeMap) Map(java.util.Map) NavigableMap(java.util.NavigableMap) SortedMap(java.util.SortedMap)

Example 39 with NavigableMap

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

the class TreeSubMapTest method testFirstKey.

/**
     * firstKey returns first key
     */
public void testFirstKey() {
    NavigableMap map = map5();
    assertEquals(one, map.firstKey());
}
Also used : NavigableMap(java.util.NavigableMap)

Example 40 with NavigableMap

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

the class TreeSubMapTest method testDescendingToString.

/**
     * toString contains toString of elements
     */
public void testDescendingToString() {
    NavigableMap map = dmap5();
    String s = map.toString();
    for (int i = 1; i <= 5; ++i) {
        assertTrue(s.contains(String.valueOf(i)));
    }
}
Also used : NavigableMap(java.util.NavigableMap)

Aggregations

NavigableMap (java.util.NavigableMap)173 Map (java.util.Map)85 TreeMap (java.util.TreeMap)62 SortedMap (java.util.SortedMap)35 ArrayList (java.util.ArrayList)34 List (java.util.List)27 HashMap (java.util.HashMap)21 Iterator (java.util.Iterator)21 Cell (org.apache.hadoop.hbase.Cell)20 Result (org.apache.hadoop.hbase.client.Result)19 Set (java.util.Set)14 Get (org.apache.hadoop.hbase.client.Get)14 IOException (java.io.IOException)12 KeyValue (org.apache.hadoop.hbase.KeyValue)11 Test (org.junit.Test)11 Put (org.apache.hadoop.hbase.client.Put)10 Entry (java.util.Map.Entry)9 Update (co.cask.cdap.data2.dataset2.lib.table.Update)7 ImmutableMap (com.google.common.collect.ImmutableMap)7 TestSuite (junit.framework.TestSuite)7