collides method

bool collides(
  1. RBushBox bbox
)

Tests if any items intersect with bbox. Use search if you need the list.

Implementation

bool collides(RBushBox bbox) {
  _RBushNode<T> node = data;

  if (!bbox.intersects(node)) return false;

  final List<_RBushNode<T>> nodesToSearch = [];

  while (true) {
    if (node.leaf) {
      for (final child in node.leafChildren) {
        if (bbox.intersects(toBBox(child))) {
          return true;
        }
      }
    } else {
      for (final child in node.children) {
        if (bbox.intersects(child)) {
          if (bbox.contains(child)) return true;
          nodesToSearch.add(child);
        }
      }
    }
    if (nodesToSearch.isEmpty) break;
    node = nodesToSearch.removeLast();
  }

  return false;
}