Search in sources :

Example 16 with NavigableMap

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

the class TreeMapTest method testSerialization.

/**
     * A deserialized map equals original
     */
public void testSerialization() throws Exception {
    NavigableMap x = map5();
    NavigableMap y = serialClone(x);
    assertNotSame(x, y);
    assertEquals(x.size(), y.size());
    assertEquals(x.toString(), y.toString());
    assertEquals(x, y);
    assertEquals(y, x);
}
Also used : NavigableMap(java.util.NavigableMap)

Example 17 with NavigableMap

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

the class TreeSubMapTest method testHigherEntry.

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

Example 18 with NavigableMap

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

the class TreeSubMapTest method testToString.

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

Example 19 with NavigableMap

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

the class TreeSubMapTest method testTailMapContents.

/**
     * headMap returns map with keys in requested range
     */
public void testTailMapContents() {
    NavigableMap map = map5();
    SortedMap sm = map.tailMap(two);
    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 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());
    SortedMap ssm = sm.tailMap(four);
    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) SortedMap(java.util.SortedMap) Iterator(java.util.Iterator) TreeMap(java.util.TreeMap) Map(java.util.Map) NavigableMap(java.util.NavigableMap) SortedMap(java.util.SortedMap)

Example 20 with NavigableMap

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

the class TreeSubMapTest method testDescendingIsEmpty.

/**
     * isEmpty is true of empty map and false for non-empty
     */
public void testDescendingIsEmpty() {
    NavigableMap empty = dmap0();
    NavigableMap map = dmap5();
    assertTrue(empty.isEmpty());
    assertFalse(map.isEmpty());
}
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