each method
Implementation
QuadTree<T> each(VisitCallback<T> callback) {
List<InnerQuad<T>> quads = [];
QuadNode<T>? node = _root;
QuadNode<T>? child;
num x0;
num y0;
num x1;
num y1;
if (node != null) {
quads.add(InnerQuad(node, _x0, _y0, _x1, _y1));
}
while (quads.isNotEmpty) {
InnerQuad<T> q = quads.removeLast();
node = q.node;
if (!callback.call(node, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1) && node.hasChild) {
int xm = ((x0 + x1) / 2).round(), ym = ((y0 + y1) / 2).round();
if ((child = node[3]) != null) quads.add(InnerQuad(child!, xm, ym, x1, y1));
if ((child = node[2]) != null) quads.add(InnerQuad(child!, x0, ym, xm, y1));
if ((child = node[1]) != null) quads.add(InnerQuad(child!, xm, y0, x1, ym));
if ((child = node[0]) != null) quads.add(InnerQuad(child!, x0, y0, xm, ym));
}
}
return this;
}