# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501, F401, F403, F405
r"""
Grid-based spatial index for fast overlap queries.

Divides the 2D plane into fixed-size cells and associates each
inserted item with the cells its bounding box touches.
"""

import builtins
import typing
__all__ = [
    "SpatialGrid",
]

@typing.final
class SpatialGrid:
    r"""
    A grid-based spatial index for fast overlap queries.
    
    Divides the 2D plane into fixed-size cells and indexes items by
    their bounding box for efficient overlap lookups.
    """
    def __new__(cls, cell_size: builtins.float) -> SpatialGrid:
        r"""
        Create a new spatial grid with the given cell size.
        
        :param cell_size: Side length of each grid cell in mm.
        """
    def insert(self, index: builtins.int, bbox: typing.Sequence[builtins.float]) -> None:
        r"""
        Insert an item into the grid by its bounding box.
        
        :param index: Unique identifier for the item.
        :param bbox: ``[x_min, y_min, x_max, y_max]`` bounding box.
        :complexity: O(1) amortised
        """
    def query(self, bbox: typing.Sequence[builtins.float]) -> builtins.list[builtins.int]:
        r"""
        Query all items whose bounding box overlaps *bbox*.
        
        :param bbox: ``[x_min, y_min, x_max, y_max]`` query region.
        :returns: Sorted list of matching item indices.
        :complexity: O(cells + k) where k = number of matching items
        """
    def remove(self, index: builtins.int, bbox: typing.Sequence[builtins.float]) -> None:
        r"""
        Remove an item from the grid by its bounding box.
        
        :param index: Unique identifier for the item.
        :param bbox: ``[x_min, y_min, x_max, y_max]`` bounding box.
        :complexity: O(cells) where cells = number of grid cells the bbox touches
        """
    def clear(self) -> None:
        r"""
        Remove all items from the grid.
        
        :complexity: O(n) where n = number of items
        """
    def __repr__(self) -> builtins.str: ...

