org.apache.ignite.ml.knn.utils

## Class PointWithDistanceUtil

- java.lang.Object
- - org.apache.ignite.ml.knn.utils.PointWithDistanceUtil

-     public class PointWithDistanceUtil
      extends Object

  Util class with method that help working with `PointWithDistance`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PointWithDistanceUtil()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <L> List<LabeledVector<L>>` | `transformToListOrdered(Queue<PointWithDistance<L>> points)` Util method that transforms collection of `PointWithDistance` to array of `LabeledVector`.
    `static <L> void` | `tryToAddIntoHeap(Queue<PointWithDistance<L>> heap, int k, LabeledVector<L> dataPnt, double distance)` Util method that adds data point into heap if it fits (if heap size is less than `k` or a distance from taget point to data point is less than a distance from target point to the most distant data point in heap).
    `static <L> void` | `tryToAddIntoHeap(Queue<PointWithDistance<L>> heap, int k, Vector pnt, List<LabeledVector<L>> dataPnts, DistanceMeasure distanceMeasure)` Util method that adds data points into heap if they fits (if heap size is less than `k` or a distance from taget point to data point is less than a distance from target point to the most distant data point in heap).

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

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

- - ### Constructor Detail

    - #### PointWithDistanceUtil

          public PointWithDistanceUtil()

  - ### Method Detail

    - #### transformToListOrdered

          public static <L> List<LabeledVector<L>> transformToListOrdered(Queue<PointWithDistance<L>> points)

      Util method that transforms collection of `PointWithDistance` to array of `LabeledVector`. Be aware that this method uses `Queue.remove()` method to extract elements and the asymptotic complexity of this method depends on it (in case of `PriorityQueue` it will be `O(log(n))`, in case of `LinkedList` it will be `O(n)`).
      Type Parameters:
        `L` - Label type.
      Parameters:
        `points` - Collections of `PointWithDistance`.
      Returns:
        Array of `LabeledVector`

    - #### tryToAddIntoHeap

          public static <L> void tryToAddIntoHeap(Queue<PointWithDistance<L>> heap,
                                                  int k,
                                                  LabeledVector<L> dataPnt,
                                                  double distance)

      Util method that adds data point into heap if it fits (if heap size is less than `k` or a distance from taget point to data point is less than a distance from target point to the most distant data point in heap).
      Type Parameters:
        `L` - Label type.
      Parameters:
        `heap` - Heap with closest points.
        `k` - Number of neighbours.
        `dataPnt` - Data point to be added.
        `distance` - Distance to target point.

    - #### tryToAddIntoHeap

          public static <L> void tryToAddIntoHeap(Queue<PointWithDistance<L>> heap,
                                                  int k,
                                                  Vector pnt,
                                                  List<LabeledVector<L>> dataPnts,
                                                  DistanceMeasure distanceMeasure)

      Util method that adds data points into heap if they fits (if heap size is less than `k` or a distance from taget point to data point is less than a distance from target point to the most distant data point in heap).
      Type Parameters:
        `L` - Label type.
      Parameters:
        `heap` - Heap with closest points.
        `k` - Number of neighbours.
        `pnt` - Point to calculate distance to.
        `dataPnts` - Data points to be added.
        `distanceMeasure` - Distance measure.

2020 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.9.1
Release Date | : December 9 2020