org.apache.ignite.ml.knn.utils.indices

## Class ArraySpatialIndex<L>

- java.lang.Object
- - org.apache.ignite.ml.knn.utils.indices.ArraySpatialIndex<L>

- Type Parameters:
    `L` - Label type.
  All Implemented Interfaces:
    AutoCloseable, SpatialIndex<L>

      public class ArraySpatialIndex<L>
      extends Object
      implements SpatialIndex<L>

  Array based implementation of `SpatialIndex`. Asymptotic runtime complexity of finding `k` closest elements is `O(n*log(k))`, but it doesn't degrade on high dimensional data.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ArraySpatialIndex(List<LabeledVector<L>> data, DistanceMeasure distanceMeasure)` Construct a new array spatial index.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<LabeledVector<L>>` | `findKClosest(int k, Vector pnt)` Finds `k` closest elements to the specified point.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.ignite.ml.knn.utils.indices.SpatialIndex

      `close`

- - ### Constructor Detail

    - #### ArraySpatialIndex

          public ArraySpatialIndex(List<LabeledVector<L>> data,
                                   DistanceMeasure distanceMeasure)

      Construct a new array spatial index.
      Parameters:
        `data` - Data.
        `distanceMeasure` - Distance measure.

  - ### Method Detail

    - #### findKClosest

          public List<LabeledVector<L>> findKClosest(int k,
                                                     Vector pnt)

      Finds `k` closest elements to the specified point.
      Specified by:
        `findKClosest` in interface `SpatialIndex<L>`
      Parameters:
        `k` - Number of elements to be returned.
        `pnt` - Point to be used to calculate distance to other points.
      Returns:
        An array of the `k` closest elements to the specified point.

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022