else if (right[p] == b) right[p] = d;
else throw new Error("rotate called with invalid parent");
size[b] = 1 + sizeof(left[b]) + sizeof(right[b]);
else if (right[p] == b) right[p] = d;
else throw new Error("rotate called with invalid parent");
size[b] = 1 + sizeof(left[b]) + sizeof(right[b]);
- size[d] = 1 + sizeof(left[d]) + sizeof(right[d]);
-
- if(DEBUG) try { check(); } catch(Error e) { System.err.println("rotate: " + toTheLeft + "," + b + "," + p); throw e; }
+ size[d] = 1 + sizeof(left[d]) + sizeof(right[d]);
balance(slot, arg);
balance(arg, 0);
} else {
if (left[p] == slot) left[p] = arg;
else if (right[p] == slot) right[p] = arg;
else throw new Error("should never happen");
balance(slot, arg);
balance(arg, 0);
} else {
if (left[p] == slot) left[p] = arg;
else if (right[p] == slot) right[p] = arg;
else throw new Error("should never happen");
if(parent[root] != 0) throw new Error("parent of the root isn't 0");
if(left[0] != 0 || right[0] != 0 || size[0] != 0 || parent[0] != 0)
throw new Error("someone messed with [0]");
if(parent[root] != 0) throw new Error("parent of the root isn't 0");
if(left[0] != 0 || right[0] != 0 || size[0] != 0 || parent[0] != 0)
throw new Error("someone messed with [0]");