FindNearestNeighborsResults

FindNearestNeighborsResults

Wrapper for the neighbor search results on the Wasm heap, typically produced by findNearestNeighbors.

Classes

FindNearestNeighborsResults

Methods

(static) unserialize(runs, indices, indices) → {FindNearestNeighborsResults}

Source:
Parameters:
Name Type Description
runs Int32WasmArray | Array | TypedArray

An array of length equal to numberOfCells(), containing the number of neighbors per cell.

indices Int32WasmArray | Array | TypedArray

An array of length equal to size(), containing the indices of the neighbors of each cell.

indices Float64WasmArray | Array | TypedArray

An array of length equal to size(), containing the distances to the neighbors of each cell.

Returns:

Object containing the unserialized search results.

Type
FindNearestNeighborsResults

free()

Source:
Returns:

Frees the memory allocated on the Wasm heap for this object. This invalidates this object and all references to it.

numberOfCells() → {number}

Source:
Returns:

The number of cells used in the search.

Type
number

serialize(optionsopt) → {object}

Source:
Parameters:
Name Type Attributes Default Description
options object <optional>
{}

Optional parameters.

Properties
Name Type Attributes Default Description
runs Int32WasmArray <optional>
<nullable>
null

A Wasm-allocated array of length equal to numberOfCells(), to be used to store the number of neighbors per cell.

indices Int32WasmArray <optional>
<nullable>
null

A Wasm-allocated array of length equal to size(), to be used to store the indices of the neighbors of each cell.

distances Float64WasmArray <optional>
<nullable>
null

A Wasm-allocated array of length equal to size(), to be used to store the distances to the neighbors of each cell.

Returns:

An object is returned with the runs, indices and distances keys, each with an appropriate TypedArray as the value.

If all of the arguments are non-null, the TypedArrays in the returned object are views on the corresponding input WasmArrays. Note that these views may be invalidated on the next allocation on the Wasm heap.

If only some of the arguments are non-null, an error is raised.

Type
object

size() → {number}

Source:
Returns:

The total number of neighbors across all cells. This is usually the product of the number of neighbors and the number of cells.

Type
number