# @zakkster/lite-spatial
> Zero-GC spatial hash grid. Linked-list chaining, epoch deduplication, box + radius queries, O(1) insert/remove.

## Install
npm i @zakkster/lite-spatial

## Dependencies
None.

## API
- new SpatialGrid(width, height, cellSize, capacity)
- .clear() — call once per frame before inserting
- .insert(id, x, y) — O(1) linked-list prepend
- .remove(id, x, y) — O(k) cell traversal removal
- .queryBox(minX, minY, maxX, maxY, outBuffer, dedupe?) → count
- .queryRadius(x, y, radius, outBuffer, dedupe?) → count
- .destroy() — nulls all typed arrays

## Key Facts
- Int32Array head[] per cell + Int32Array next[] linked-list — zero object allocation
- _invCell precomputed for multiply-instead-of-divide in hot path
- Epoch-based Uint8 deduplication marker — flushes every 255 queries, not per query
- outBuffer pattern: caller pre-allocates Int32Array, grid fills it
- capacity-aligned: matches SoaParticleEngine pool size
- Bounds-checked insert: out-of-bounds coordinates silently ignored
- Early exit when outBuffer is full
