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