@Test public void test_find_children(){ BTreeMap m = new BTreeMap(engine,32,true,false, null,null,null,null); assertEquals(8,m.findChildren(11, new Integer[]{1,2,3,4,5,6,7,8})); assertEquals(0,m.findChildren(1, new Integer[]{1,2,3,4,5,6,7,8})); assertEquals(0,m.findChildren(0, new Integer[]{1,2,3,4,5,6,7,8})); assertEquals(7,m.findChildren(8, new Integer[]{1,2,3,4,5,6,7,8})); assertEquals(4,m.findChildren(49, new Integer[]{10,20,30,40,50})); assertEquals(4,m.findChildren(50, new Integer[]{10,20,30,40,50})); assertEquals(3,m.findChildren(40, new Integer[]{10,20,30,40,50})); assertEquals(3,m.findChildren(39, new Integer[]{10,20,30,40,50})); }
protected final int findChildren(final Object key, final Object[] keys) { int left = 0; if(keys[0] == null) left++; int right = keys[keys.length-1] == null ? keys.length-1 : keys.length; int middle; while (true) { middle = (left + right) / 2; if(keys[middle]==null) return middle; if (comparator.compare(keys[middle], key) < 0) { left = middle + 1; } else { right = middle; } if (left >= right) { return right; } } }
BTreeMap extends AbstractMap<K,V> implements ConcurrentNavigableMap<K,V>, Bind.MapWithModificationListener<K,V> { protected final int findChildren(final Object key, final Object[] keys) { int left = 0; if(keys[0] == null) left++; int right = keys[keys.length-1] == null ? keys.length-1 : keys.length; int middle; while (true) { middle = (left + right) / 2; if(keys[middle]==null) return middle; if (comparator.compare(keys[middle], key) < 0) { left = middle + 1; } else { right = middle; } if (left >= right) { return right; } } } }
BTreeMap extends AbstractMap<K,V> implements ConcurrentNavigableMap<K,V>, Bind.MapWithModificationListener<K,V> { protected final int findChildren(final Object key, final Object[] keys) { int left = 0; if(keys[0] == null) left++; int right = keys[keys.length-1] == null ? keys.length-1 : keys.length; int middle; while (true) { middle = (left + right) / 2; if(keys[middle]==null) return middle; if (comparator.compare(keys[middle], key) < 0) { left = middle + 1; } else { right = middle; } if (left >= right) { return right; } } } 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); }
BTreeMap extends AbstractMap<K,V> implements ConcurrentNavigableMap<K,V>, Bind.MapWithModificationListener<K,V> { protected final int findChildren(final Object key, final Object[] keys) { int left = 0; if(keys[0] == null) left++; int right = keys[keys.length-1] == null ? keys.length-1 : keys.length; int middle; while (true) { middle = (left + right) / 2; if(keys[middle]==null) return middle; if (comparator.compare(keys[middle], key) < 0) { left = middle + 1; } else { right = middle; } if (left >= right) { return right; } } } 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(); }
BTreeMap extends AbstractMap<K,V> implements ConcurrentNavigableMap<K,V>, Bind.MapWithModificationListener<K,V> { protected final int findChildren(final Object key, final Object[] keys) { int left = 0; if(keys[0] == null) left++; int right = keys[keys.length-1] == null ? keys.length-1 : keys.length; int middle; while (true) { middle = (left + right) / 2; if(keys[middle]==null) return middle; if (comparator.compare(keys[middle], key) < 0) { left = middle + 1; } else { right = middle; } if (left >= right) { return right; } } } 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();  }