Search in sources :

Example 21 with NavigableMap

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

the class TreeSubMapTest method testContainsValue.

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

Example 22 with NavigableMap

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

the class TreeMapTest method testTailMapContents.

/**
     * headMap returns map with keys in requested range
     */
public void testTailMapContents() {
    TreeMap map = map5();
    NavigableMap sm = map.tailMap(two, true);
    assertFalse(sm.containsKey(one));
    assertTrue(sm.containsKey(two));
    assertTrue(sm.containsKey(three));
    assertTrue(sm.containsKey(four));
    assertTrue(sm.containsKey(five));
    Iterator i = sm.keySet().iterator();
    Object k;
    k = (Integer) (i.next());
    assertEquals(two, k);
    k = (Integer) (i.next());
    assertEquals(three, k);
    k = (Integer) (i.next());
    assertEquals(four, k);
    k = (Integer) (i.next());
    assertEquals(five, k);
    assertFalse(i.hasNext());
    Iterator r = sm.descendingKeySet().iterator();
    k = (Integer) (r.next());
    assertEquals(five, k);
    k = (Integer) (r.next());
    assertEquals(four, k);
    k = (Integer) (r.next());
    assertEquals(three, k);
    k = (Integer) (r.next());
    assertEquals(two, k);
    assertFalse(r.hasNext());
    Iterator ei = sm.entrySet().iterator();
    Map.Entry e;
    e = (Map.Entry) (ei.next());
    assertEquals(two, e.getKey());
    assertEquals("B", e.getValue());
    e = (Map.Entry) (ei.next());
    assertEquals(three, e.getKey());
    assertEquals("C", e.getValue());
    e = (Map.Entry) (ei.next());
    assertEquals(four, e.getKey());
    assertEquals("D", e.getValue());
    e = (Map.Entry) (ei.next());
    assertEquals(five, e.getKey());
    assertEquals("E", e.getValue());
    assertFalse(i.hasNext());
    NavigableMap ssm = sm.tailMap(four, true);
    assertEquals(four, ssm.firstKey());
    assertEquals(five, ssm.lastKey());
    assertEquals("D", ssm.remove(four));
    assertEquals(1, ssm.size());
    assertEquals(3, sm.size());
    assertEquals(4, map.size());
}
Also used : NavigableMap(java.util.NavigableMap) Iterator(java.util.Iterator) TreeMap(java.util.TreeMap) NavigableMap(java.util.NavigableMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 23 with NavigableMap

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

the class TreeSubMapTest method testDescendingPutAll.

/**
     * putAll adds all key-value pairs from the given map
     */
public void testDescendingPutAll() {
    NavigableMap empty = dmap0();
    NavigableMap map = dmap5();
    empty.putAll(map);
    assertEquals(5, empty.size());
    assertTrue(empty.containsKey(m1));
    assertTrue(empty.containsKey(m2));
    assertTrue(empty.containsKey(m3));
    assertTrue(empty.containsKey(m4));
    assertTrue(empty.containsKey(m5));
}
Also used : NavigableMap(java.util.NavigableMap)

Example 24 with NavigableMap

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

the class TreeSubMapTest method testDescendingPollFirstEntry.

/**
     * pollFirstEntry returns entries in order
     */
public void testDescendingPollFirstEntry() {
    NavigableMap map = dmap5();
    Map.Entry e = map.pollFirstEntry();
    assertEquals(m1, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(m2, e.getKey());
    map.put(m1, "A");
    e = map.pollFirstEntry();
    assertEquals(m1, e.getKey());
    assertEquals("A", e.getValue());
    e = map.pollFirstEntry();
    assertEquals(m3, e.getKey());
    map.remove(m4);
    e = map.pollFirstEntry();
    assertEquals(m5, e.getKey());
    try {
        e.setValue("A");
        shouldThrow();
    } catch (UnsupportedOperationException success) {
    }
    e = map.pollFirstEntry();
    assertNull(e);
}
Also used : NavigableMap(java.util.NavigableMap) TreeMap(java.util.TreeMap) Map(java.util.Map) NavigableMap(java.util.NavigableMap) SortedMap(java.util.SortedMap)

Example 25 with NavigableMap

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

the class TreeSubMapTest method testContainsKey.

/**
     * containsKey returns true for contained key
     */
public void testContainsKey() {
    NavigableMap map = map5();
    assertTrue(map.containsKey(one));
    assertFalse(map.containsKey(zero));
}
Also used : NavigableMap(java.util.NavigableMap)

Aggregations

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