import { BoundedObject, Bounds } from './utils/bounds'; export interface HashGridConfig { /** * The width of a grid cell. * @default 48 */ cellWidth: number; /** * The height of a grid cell. * @default 48 */ cellHeight: number; } /** * A spatial grid that uses a hash grid. * This class divides the space into grid cells and stores objects in * those cells. * * Important Note: * It uses bitwise operations to convert X and Y coordinates into column * and row. This means that there's a maximum of 2^16 columns and 2^16 rows. * So if the cell width and height are 48, the maximum width and height of * the space is 48 * 2^16 = 3145728 which is probably enough for most cases. */ export declare class HashGrid { private readonly _config; private _cells; private _cellWidthShift; private _cellHeightShift; constructor(config?: Partial); /** * Clears the hash grid. * * @timeComplexity `O(1)` */ clear(): void; /** * Inserts an item into the hash grid. * * @param item The item to insert. * * @timeComplexity `O(k)`, where `k` is the number of grid * cells the item overlaps. */ insert(item: T): void; /** * Retrieves all objects that are stored in grid cells overlapping * the given bounds. * * @param location The bounding box or object location to retrieve the * other objects from. * * @returns An array of objects that might intersect with the given location. * * @timeComplexity `O(k)`, where `k` is the number of overlapping grid cells. */ retrieve(location: T | Bounds | BoundedObject): T[]; /** * Sets the width of each grid cell. * * @param cellWidth The new cell width. * * @timeComplexity `O(1)` */ setCellWidth(cellWidth: number): void; /** * Sets the height of each grid cell. * * @param cellHeight The new cell height. * * @timeComplexity `O(1)` */ setCellHeight(cellHeight: number): void; /** * Get the hash key of X and Y coordinates. This assumes that * X and Y have been converted into column and row indices respectively. * * @param x The column index. * @param y The row index. * * @returns {number} A number that represents the hash key. */ private _getHashKey; /** * Convert Y coordinate into row index. * * @param y The Y coordinate to convert into row index. * * @returns {number} The row index of the Y coordinate. */ private _getRowIndex; /** * Convert X coordinate into column index. * * @param x The X coordinate to convert into column index. * * @returns {number} The column index of the X coordinate. */ private _getColumnIndex; get config(): HashGridConfig; }