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());
}
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"));
}
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);
}
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);
}
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));
}
Aggregations