/** * move the Cursor one item, either forwards or backwards * @param forwards direction of travel * @return false iff the cursor is exhausted in the direction of travel */ int moveOne(boolean forwards) { NodeCursor<K> cur = this.cur; if (cur.isLeaf()) { // if we're a leaf, we try to step forwards inside ourselves if (cur.advanceLeafNode(forwards)) return cur.globalLeafIndex(); // if we fail, we just find our bounding parent this.cur = cur = moveOutOfLeaf(forwards, cur, root()); return cur.globalIndex(); } // otherwise we descend directly into our next child if (forwards) ++cur.position; cur = cur.descend(); // and go to its first item NodeCursor<K> next; while ( null != (next = cur.descendToFirstChild(forwards)) ) cur = next; this.cur = cur; return cur.globalLeafIndex(); }
/** * move the Cursor one item, either forwards or backwards * @param forwards direction of travel * @return false iff the cursor is exhausted in the direction of travel */ int moveOne(boolean forwards) { NodeCursor<K> cur = this.cur; if (cur.isLeaf()) { // if we're a leaf, we try to step forwards inside ourselves if (cur.advanceLeafNode(forwards)) return cur.globalLeafIndex(); // if we fail, we just find our bounding parent this.cur = cur = moveOutOfLeaf(forwards, cur, root()); return cur.globalIndex(); } // otherwise we descend directly into our next child if (forwards) ++cur.position; cur = cur.descend(); // and go to its first item NodeCursor<K> next; while ( null != (next = cur.descendToFirstChild(forwards)) ) cur = next; this.cur = cur; return cur.globalLeafIndex(); }
/** * move the Cursor one item, either forwards or backwards * @param forwards direction of travel * @return false iff the cursor is exhausted in the direction of travel */ int moveOne(boolean forwards) { NodeCursor<K> cur = this.cur; if (cur.isLeaf()) { // if we're a leaf, we try to step forwards inside ourselves if (cur.advanceLeafNode(forwards)) return cur.globalLeafIndex(); // if we fail, we just find our bounding parent this.cur = cur = moveOutOfLeaf(forwards, cur, root()); return cur.globalIndex(); } // otherwise we descend directly into our next child if (forwards) ++cur.position; cur = cur.descend(); // and go to its first item NodeCursor<K> next; while ( null != (next = cur.descendToFirstChild(forwards)) ) cur = next; this.cur = cur; return cur.globalLeafIndex(); }
/** * move the Cursor one item, either forwards or backwards * @param forwards direction of travel * @return false iff the cursor is exhausted in the direction of travel */ int moveOne(boolean forwards) { NodeCursor<K> cur = this.cur; if (cur.isLeaf()) { // if we're a leaf, we try to step forwards inside ourselves if (cur.advanceLeafNode(forwards)) return cur.globalLeafIndex(); // if we fail, we just find our bounding parent this.cur = cur = moveOutOfLeaf(forwards, cur, root()); return cur.globalIndex(); } // otherwise we descend directly into our next child if (forwards) ++cur.position; cur = cur.descend(); // and go to its first item NodeCursor<K> next; while ( null != (next = cur.descendToFirstChild(forwards)) ) cur = next; this.cur = cur; return cur.globalLeafIndex(); }