updateNode method

bool updateNode(
  1. Node<E> node,
  2. Size nodeSize,
  3. Offset oldPosition
)

Updates a node's position in the QuadTree

This is more efficient than remove + insert for position updates

Implementation

bool updateNode(Node<E> node, Size nodeSize, Offset oldPosition) {
  // Remove from old position using a copy of the node with old position
  final currentPosition = node.position;
  node.position = oldPosition;
  final removed = remove(node, nodeSize);

  // Restore current position and insert
  node.position = currentPosition;
  if (removed) {
    return insert(node, nodeSize);
  }

  // If not found at old position, try inserting anyway
  return insert(node, nodeSize);
}