Interface KNNList

  • All Superinterfaces:
    DBIDs, DoubleDBIDList
    All Known Implementing Classes:
    DoubleIntegerDBIDKNNList, IntegerDBIDKNNSubList

    public interface KNNList
    extends DoubleDBIDList
    Interface for kNN results.

    To iterate over the results, use the following code:

     
     for (DistanceDBIDResultIter<D> iter = result.iter(); iter.valid(); iter.advance()) {
       // You can get the distance via: iter.getDistance();
       // Or use iter just like any other DBIDRef
     }
     
     
    If you are only interested in the IDs of the objects, the following is also sufficient:
     
     for (DBIDIter<D> iter = result.iter(); iter.valid(); iter.advance()) {
       // Use iter just like any other DBIDRef
     }
     
     
    Since:
    0.5.5
    Author:
    Erich Schubert
    • Method Detail

      • getK

        int getK()
        Get the K parameter (note: this may be less than the size of the list!)
        Returns:
        K
      • getKNNDistance

        double getKNNDistance()
        Get the distance to the k nearest neighbor, or infinity otherwise.
        Returns:
        Maximum distance
      • subList

        KNNList subList​(int k)
        Select a subset for a smaller k.
        Parameters:
        k - New k
        Returns:
        KNN result for the smaller k.
      • map

        KNNList map​(java.util.function.DoubleUnaryOperator f)
        Function to project the knn list.
        Parameters:
        f - Function to transform values
        Returns:
        projected list