forEach method
Visit all objects in this QuadTree. The walk stops when it iterates over all objects or when the callback returns false.
Implementation
void forEach(
bool Function(
int id,
double left,
double top,
double width,
double height,
) cb,
) {
final root = _root;
if (root == null) return;
var offset = 0;
if (root._subdivided) {
for (var i = 0; i < _nextObjectId; i++) {
if (_id2node[i] == 0) continue;
offset = i * _objectSize;
final next = cb(
i, // id of the object
_objects[offset + 0], // left
_objects[offset + 1], // top
_objects[offset + 2], // width
_objects[offset + 3], // height
);
if (next) continue;
break;
}
} else {
final rootIds = root._ids;
for (final id in rootIds) {
offset = id * _objectSize;
final next = cb(
id, // id of the object
_objects[offset + 0], // left
_objects[offset + 1], // top
_objects[offset + 2], // width
_objects[offset + 3], // height
);
if (next) continue;
break;
}
}
}