removeWithNode method
Implementation
bool removeWithNode(Object searchBounds, AbstractNode node, Object item) {
// first try removing item from this node
bool found = removeItem(node, item);
if (found) return true;
AbstractNode? childToPrune = null;
// next try removing item from lower nodes
for (Iterator i = node.getChildBoundables().iterator; i.moveNext();) {
Boundable childBoundable = i.current as Boundable;
if (!getIntersectsOp()
.intersects(childBoundable.getBounds(), searchBounds)) {
continue;
}
if (childBoundable is AbstractNode) {
found =
removeWithNode(searchBounds, childBoundable as AbstractNode, item);
// if found, record child for pruning and exit
if (found) {
childToPrune = childBoundable as AbstractNode;
break;
}
}
}
// prune child if possible
if (childToPrune != null) {
if (childToPrune.getChildBoundables().isEmpty) {
node.getChildBoundables().remove(childToPrune);
}
}
return found;
}