/** * The parent that covers a range wider than ourselves, either ascending or descending, * i.e. that defines the upper or lower bound on the subtree rooted at our node * @param upper * @return the NodeCursor parent that can tell us the upper/lower bound of ourselves */ NodeCursor<K> boundIterator(boolean upper) { NodeCursor<K> bound = this.parent; while (bound != null && (upper ? bound.position >= getChildCount(bound.node) - 1 : bound.position <= 0)) bound = bound.parent; return bound; }
/** * The parent that covers a range wider than ourselves, either ascending or descending, * i.e. that defines the upper or lower bound on the subtree rooted at our node * @param upper * @return the NodeCursor parent that can tell us the upper/lower bound of ourselves */ NodeCursor<K> boundIterator(boolean upper) { NodeCursor<K> bound = this.parent; while (bound != null && (upper ? bound.position >= getChildCount(bound.node) - 1 : bound.position <= 0)) bound = bound.parent; return bound; }
/** * The parent that covers a range wider than ourselves, either ascending or descending, * i.e. that defines the upper or lower bound on the subtree rooted at our node * @param upper * @return the NodeCursor parent that can tell us the upper/lower bound of ourselves */ NodeCursor<K> boundIterator(boolean upper) { NodeCursor<K> bound = this.parent; while (bound != null && (upper ? bound.position >= getChildCount(bound.node) - 1 : bound.position <= 0)) bound = bound.parent; return bound; }
/** * The parent that covers a range wider than ourselves, either ascending or descending, * i.e. that defines the upper or lower bound on the subtree rooted at our node * @param upper * @return the NodeCursor parent that can tell us the upper/lower bound of ourselves */ NodeCursor<K> boundIterator(boolean upper) { NodeCursor<K> bound = this.parent; while (bound != null && (upper ? bound.position >= getChildCount(bound.node) - 1 : bound.position <= 0)) bound = bound.parent; return bound; }
private static int copyChildren(final Object[] from, final Object[] to, final int offset, final int skipIndex) { assert !BTree.isLeaf(from); final int start = BTree.getChildStart(from); final int childCount = BTree.getChildCount(from); if (skipIndex > 0) System.arraycopy(from, start, to, offset, skipIndex); if (skipIndex + 1 <= childCount) System.arraycopy(from, start + skipIndex + 1, to, offset + skipIndex, childCount - skipIndex - 1); return offset + childCount - 1; }
private static int copyChildren(final Object[] from, final Object[] to, final int offset, final int skipIndex) { assert !BTree.isLeaf(from); final int start = BTree.getChildStart(from); final int childCount = BTree.getChildCount(from); if (skipIndex > 0) System.arraycopy(from, start, to, offset, skipIndex); if (skipIndex + 1 <= childCount) System.arraycopy(from, start + skipIndex + 1, to, offset + skipIndex, childCount - skipIndex - 1); return offset + childCount - 1; }
private static int copyChildren(final Object[] from, final Object[] to, final int offset, final int skipIndex) { assert !BTree.isLeaf(from); final int start = BTree.getChildStart(from); final int childCount = BTree.getChildCount(from); if (skipIndex > 0) System.arraycopy(from, start, to, offset, skipIndex); if (skipIndex + 1 <= childCount) System.arraycopy(from, start + skipIndex + 1, to, offset + skipIndex, childCount - skipIndex - 1); return offset + childCount - 1; }
private static int copyChildren(final Object[] from, final Object[] to, final int offset) { assert !BTree.isLeaf(from); final int start = BTree.getChildStart(from); final int childCount = BTree.getChildCount(from); System.arraycopy(from, start, to, offset, childCount); return offset + childCount; }
private static int copyChildren(final Object[] from, final Object[] to, final int offset, final int skipIndex) { assert !BTree.isLeaf(from); final int start = BTree.getChildStart(from); final int childCount = BTree.getChildCount(from); if (skipIndex > 0) System.arraycopy(from, start, to, offset, skipIndex); if (skipIndex + 1 <= childCount) System.arraycopy(from, start + skipIndex + 1, to, offset + skipIndex, childCount - skipIndex - 1); return offset + childCount - 1; }
private static int copyChildren(final Object[] from, final Object[] to, final int offset) { assert !BTree.isLeaf(from); final int start = BTree.getChildStart(from); final int childCount = BTree.getChildCount(from); System.arraycopy(from, start, to, offset, childCount); return offset + childCount; }
private static int copyChildren(final Object[] from, final Object[] to, final int offset) { assert !BTree.isLeaf(from); final int start = BTree.getChildStart(from); final int childCount = BTree.getChildCount(from); System.arraycopy(from, start, to, offset, childCount); return offset + childCount; }
private static int copyChildren(final Object[] from, final Object[] to, final int offset) { assert !BTree.isLeaf(from); final int start = BTree.getChildStart(from); final int childCount = BTree.getChildCount(from); System.arraycopy(from, start, to, offset, childCount); return offset + childCount; }
NodeCursor<K> descendToFirstChild(boolean forwards) { if (isLeaf()) { position = forwards ? 0 : getLeafKeyEnd(node) - 1; return null; } inChild = true; position = forwards ? 0 : getChildCount(node) - 1; return descend(); }
NodeCursor<K> descendToFirstChild(boolean forwards) { if (isLeaf()) { position = forwards ? 0 : getLeafKeyEnd(node) - 1; return null; } inChild = true; position = forwards ? 0 : getChildCount(node) - 1; return descend(); }
NodeCursor<K> descendToFirstChild(boolean forwards) { if (isLeaf()) { position = forwards ? 0 : getLeafKeyEnd(node) - 1; return null; } inChild = true; position = forwards ? 0 : getChildCount(node) - 1; return descend(); }
NodeCursor<K> descendToFirstChild(boolean forwards) { if (isLeaf()) { position = forwards ? 0 : getLeafKeyEnd(node) - 1; return null; } inChild = true; position = forwards ? 0 : getChildCount(node) - 1; return descend(); }
private static Object[] rotateRight(final Object[] node, final int i) { final int keyEnd = BTree.getBranchKeyEnd(node); final Object[] nextNode = (Object[]) node[keyEnd + i]; final Object[] rightNeighbour = (Object[]) node[keyEnd + i + 1]; final boolean leaves = BTree.isLeaf(nextNode); final int nextKeyEnd = BTree.getKeyEnd(nextNode); final Object[] newChild = leaves ? null : (Object[]) rightNeighbour[BTree.getChildStart(rightNeighbour)]; final Object[] newNextNode = copyWithKeyAndChildInserted(nextNode, nextKeyEnd, node[i], BTree.getChildCount(nextNode), newChild); node[i] = rightNeighbour[0]; node[keyEnd + i + 1] = copyWithKeyAndChildRemoved(rightNeighbour, 0, 0, true); BTree.getSizeMap(node)[i] += leaves ? 1 : 1 + BTree.size((Object[]) newNextNode[BTree.getChildEnd(newNextNode) - 1]); return newNextNode; }
private static Object[] rotateRight(final Object[] node, final int i) { final int keyEnd = BTree.getBranchKeyEnd(node); final Object[] nextNode = (Object[]) node[keyEnd + i]; final Object[] rightNeighbour = (Object[]) node[keyEnd + i + 1]; final boolean leaves = BTree.isLeaf(nextNode); final int nextKeyEnd = BTree.getKeyEnd(nextNode); final Object[] newChild = leaves ? null : (Object[]) rightNeighbour[BTree.getChildStart(rightNeighbour)]; final Object[] newNextNode = copyWithKeyAndChildInserted(nextNode, nextKeyEnd, node[i], BTree.getChildCount(nextNode), newChild); node[i] = rightNeighbour[0]; node[keyEnd + i + 1] = copyWithKeyAndChildRemoved(rightNeighbour, 0, 0, true); BTree.getSizeMap(node)[i] += leaves ? 1 : 1 + BTree.size((Object[]) newNextNode[BTree.getChildEnd(newNextNode) - 1]); return newNextNode; }
private static Object[] rotateRight(final Object[] node, final int i) { final int keyEnd = BTree.getBranchKeyEnd(node); final Object[] nextNode = (Object[]) node[keyEnd + i]; final Object[] rightNeighbour = (Object[]) node[keyEnd + i + 1]; final boolean leaves = BTree.isLeaf(nextNode); final int nextKeyEnd = BTree.getKeyEnd(nextNode); final Object[] newChild = leaves ? null : (Object[]) rightNeighbour[BTree.getChildStart(rightNeighbour)]; final Object[] newNextNode = copyWithKeyAndChildInserted(nextNode, nextKeyEnd, node[i], BTree.getChildCount(nextNode), newChild); node[i] = rightNeighbour[0]; node[keyEnd + i + 1] = copyWithKeyAndChildRemoved(rightNeighbour, 0, 0, true); BTree.getSizeMap(node)[i] += leaves ? 1 : 1 + BTree.size((Object[]) newNextNode[BTree.getChildEnd(newNextNode) - 1]); return newNextNode; }
private static Object[] rotateRight(final Object[] node, final int i) { final int keyEnd = BTree.getBranchKeyEnd(node); final Object[] nextNode = (Object[]) node[keyEnd + i]; final Object[] rightNeighbour = (Object[]) node[keyEnd + i + 1]; final boolean leaves = BTree.isLeaf(nextNode); final int nextKeyEnd = BTree.getKeyEnd(nextNode); final Object[] newChild = leaves ? null : (Object[]) rightNeighbour[BTree.getChildStart(rightNeighbour)]; final Object[] newNextNode = copyWithKeyAndChildInserted(nextNode, nextKeyEnd, node[i], BTree.getChildCount(nextNode), newChild); node[i] = rightNeighbour[0]; node[keyEnd + i + 1] = copyWithKeyAndChildRemoved(rightNeighbour, 0, 0, true); BTree.getSizeMap(node)[i] += leaves ? 1 : 1 + BTree.size((Object[]) newNextNode[BTree.getChildEnd(newNextNode) - 1]); return newNextNode; }