collections/spatial_grid_utils library

Uniform spatial grid index for 2D points — roadmap #506.

Buckets points into fixed-size square cells so that "everything near (x, y)" can be answered by scanning only the handful of cells overlapping the query region, instead of testing every stored point. This is the lightweight alternative to a quadtree: it has no rebalancing, costs O(1) per insert, and a radius query touches O((2r / cellSize)^2) cells. It is ideal when points are roughly evenly spread; very clumped data degrades toward a linear scan within the hot cells.

The cell size is the central tuning knob: too small wastes memory on empty cells, too large makes each cell a mini linear scan. A good default is the typical query radius.

Classes

SpatialGrid<T>
A grid index mapping 2D points to payloads of type T.