// Tree Handling //////////////////////////////////////////////////////////////////////
- // FIXME inefficient
- public final Box nextSibling() {
- int index = parent.indexNode(this);
- if (index >= parent.treeSize() - 1) return null;
- return parent.getChild(index + 1);
- }
-
- // FIXME inefficient
- public final Box prevSibling() {
- int index = parent.indexNode(this);
- if (index <= 0) return null;
- return parent.getChild(index - 1);
- }
-
+ public final int getIndexInParent() { return parent == null ? 0 : parent.indexNode(this); }
+ public final Box nextSibling() { return parent.getChild(parent.indexNode(this) + 1); }
+ public final Box prevSibling() { return parent.getChild(parent.indexNode(this) - 1); }
public final Box getChild(int i) {
if (i < 0) return null;
if (i >= treeSize()) return null;
return (Box)getNode(i);
}
- public final int getIndexInParent() { return parent == null ? 0 : parent.indexNode(this); }
// Tree Manipulation /////////////////////////////////////////////////////////////////////
}
}
- return objects[get(index, root)];
+ cached_index = index;
+ cached_slot = get(index, root);
+ return objects[cached_slot];
}
/** deletes the object at index, returning the deleted object */