/* default */ Collection<T> get(final Rect bounds, final Collection<T> values) { if (this.hasChilds) { if (this.northwest.bounds.intersects(bounds)) { this.northwest.get(bounds, values); } if (this.northeast.bounds.intersects(bounds)) { this.northeast.get(bounds, values); } if (this.southeast.bounds.intersects(bounds)) { this.southeast.get(bounds, values); } if (this.southwest.bounds.intersects(bounds)) { this.southwest.get(bounds, values); } return values; } // no more childs, so we must contain the closest object if (this.leaves != null) { for (Leaf<T> leaf : this.leaves) { if (bounds.containsOrEquals(leaf.x, leaf.y)) { if (leaf.value != null) { values.add(leaf.value); } else { values.addAll(leaf.values); } } } } return values; }
/* default */ int execute(final Rect globalBounds, final Executor<T> executor) { int count = 0; if (this.hasChilds) { if (this.northwest.bounds.intersects(globalBounds)) { count += this.northwest.execute(globalBounds, executor); if (this.northeast.bounds.intersects(globalBounds)) { count += this.northeast.execute(globalBounds, executor); if (this.southeast.bounds.intersects(globalBounds)) { count += this.southeast.execute(globalBounds, executor); if (this.southwest.bounds.intersects(globalBounds)) { count += this.southwest.execute(globalBounds, executor);