BTreeMap extends AbstractMap<K,V> implements ConcurrentNavigableMap<K,V>, Bind.MapWithModificationListener<K,V> { protected long nextDir(DirNode d, Object key) { int pos = findChildren(key, d.keys) - 1; if(pos<0) pos = 0; return d.child[pos]; } BTreeMap(Engine engine, int maxNodeSize, boolean hasValues, boolean valsOutsideNodes,
                    Serializer defaultSerializer,
                    BTreeKeySerializer<K> keySerializer, Serializer<V> valueSerializer, Comparator<K> comparator);  BTreeMap(Engine engine, long recid, Serializer defaultSerializer); @Override V get(Object key); @Override V put(K key, V value); @Override V remove(Object key); @Override void clear(); @Override boolean isEmpty(); @Override int size(); @Override V putIfAbsent(K key, V value); @Override boolean remove(Object key, Object value); @Override boolean replace(K key, V oldValue, V newValue); @Override V replace(K key, V value); @Override Comparator<? super K> comparator(); @Override Map.Entry<K,V> firstEntry(); @Override Entry<K, V> pollFirstEntry(); @Override Entry<K, V> pollLastEntry(); @Override Map.Entry<K,V> lastEntry(); @Override Map.Entry<K,V> lowerEntry(K key); @Override K lowerKey(K key); @Override Map.Entry<K,V> floorEntry(K key); @Override K floorKey(K key); @Override Map.Entry<K,V> ceilingEntry(K key); @Override K ceilingKey(K key); @Override Map.Entry<K,V> higherEntry(K key); @Override K higherKey(K key); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override K firstKey(); @Override K lastKey(); @Override ConcurrentNavigableMap<K,V> subMap(K fromKey,
                                              boolean fromInclusive,
                                              K toKey,
                                              boolean toInclusive); @Override ConcurrentNavigableMap<K,V> headMap(K toKey,
                                               boolean inclusive); @Override ConcurrentNavigableMap<K,V> tailMap(K fromKey,
                                               boolean inclusive); @Override ConcurrentNavigableMap<K,V> subMap(K fromKey, K toKey); @Override ConcurrentNavigableMap<K,V> headMap(K toKey); @Override ConcurrentNavigableMap<K,V> tailMap(K fromKey); @Override NavigableSet<K> keySet(); @Override NavigableSet<K> navigableKeySet(); @Override Collection<V> values(); @Override Set<Map.Entry<K,V>> entrySet(); @Override ConcurrentNavigableMap<K,V> descendingMap(); @Override NavigableSet<K> descendingKeySet(); NavigableMap<K,V> snapshot(); @Override void addModificationListener(Bind.MapListener<K,V> listener); @Override void removeModificationListener(Bind.MapListener<K,V> listener); void close(); void printTreeStructure();  }
@Test public void test_next_dir(){ BTreeMap m = new BTreeMap(engine,32,true,false, null,null,null,null); BTreeMap.DirNode d = new BTreeMap.DirNode(new Integer[]{44,62,68, 71}, new long[]{10,20,30,40}); assertEquals(10, m.nextDir(d, 62)); assertEquals(10, m.nextDir(d, 44)); assertEquals(10, m.nextDir(d, 48)); assertEquals(20, m.nextDir(d, 63)); assertEquals(20, m.nextDir(d, 64)); assertEquals(20, m.nextDir(d, 68)); assertEquals(30, m.nextDir(d, 69)); assertEquals(30, m.nextDir(d, 70)); assertEquals(30, m.nextDir(d, 71)); assertEquals(40, m.nextDir(d, 72)); assertEquals(40, m.nextDir(d, 73)); }
@Test public void test_next_dir_infinity(){ BTreeMap m = new BTreeMap(engine,32,true,false, null,null,null,null); BTreeMap.DirNode d = new BTreeMap.DirNode( new Object[]{null,62,68, 71}, new long[]{10,20,30,40}); assertEquals(10, m.nextDir(d, 33)); assertEquals(10, m.nextDir(d, 62)); assertEquals(20, m.nextDir(d, 63)); d = new BTreeMap.DirNode( new Object[]{44,62,68, null}, new long[]{10,20,30,40}); assertEquals(10, m.nextDir(d, 62)); assertEquals(10, m.nextDir(d, 44)); assertEquals(10, m.nextDir(d, 48)); assertEquals(20, m.nextDir(d, 63)); assertEquals(20, m.nextDir(d, 64)); assertEquals(20, m.nextDir(d, 68)); assertEquals(30, m.nextDir(d, 69)); assertEquals(30, m.nextDir(d, 70)); assertEquals(30, m.nextDir(d, 71)); assertEquals(30, m.nextDir(d, 72)); assertEquals(30, m.nextDir(d, 73)); }