interface Quadtree<T> {
    size: number;
    bounds: Readonly<Bounds>;
    insert(item: Readonly<T>): void;
    search(area: Readonly<Bounds>): IterableIterator<Readonly<T>>;
    all(): IterableIterator<Readonly<T>>;
    collect(area: Readonly<Bounds>, result?: Readonly<T>[]): Readonly<T>[];
    collectAll(result?: Readonly<T>[]): Readonly<T>[];
    remove(item: Readonly<T>): boolean;
    clear(): void;
}

Type Parameters

  • T

    The type of children of this Quadtree contains.

Properties

size: number

Count the total number of items in the Quadtree.

bounds: Readonly<Bounds>

The bounds of this Quadtree.

Methods

  • Collect items in the Quadtree that intersect with the search area into result.

    Parameters

    • area: Readonly<Bounds>

      The search area of the query.

    • Optionalresult: Readonly<T>[]

      An optional array to collect items. Defaults to an empty array.

    Returns Readonly<T>[]

    A reference to the collection array.

  • Collect all items in the Quadtree into result.

    Parameters

    • Optionalresult: Readonly<T>[]

      An optional array to collect items. Defaults to an empty array.

    Returns Readonly<T>[]

    A reference to the collection array.

  • Clear all items from the Quadtree and reset the tree back to its initial state.

    Returns void