/** * Find a node in this tree. */ public int find() { for (int node = root; node != NIL; ) { final int cmp = compare(node); if (cmp < 0) { node = left(node); } else if (cmp > 0) { node = right(node); } else { return node; } } return NIL; }
/** * Update <code>node</code> with the current data. */ public void update(int node) { final int prev = prev(node); final int next = next(node); if ((prev == NIL || compare(prev) > 0) && (next == NIL || compare(next) < 0)) { // Update can be done in-place copy(node); for (int n = node; n != NIL; n = parent(n)) { fixAggregates(n); } } else { // TODO: it should be possible to find the new node position without // starting from scratch remove(node); add(); } }
int cmp; do { cmp = compare(node); if (cmp < 0) { parent = node;
/** * Find a node in this tree. */ public int find() { for (int node = root; node != NIL; ) { final int cmp = compare(node); if (cmp < 0) { node = left(node); } else if (cmp > 0) { node = right(node); } else { return node; } } return NIL; }
/** * Update <code>node</code> with the current data. */ public void update(int node) { final int prev = prev(node); final int next = next(node); if ((prev == NIL || compare(prev) > 0) && (next == NIL || compare(next) < 0)) { // Update can be done in-place copy(node); for (int n = node; n != NIL; n = parent(n)) { fixAggregates(n); } } else { // TODO: it should be possible to find the new node position without // starting from scratch remove(node); add(); } }
int cmp; do { cmp = compare(node); if (cmp < 0) { parent = node;