<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/BNNS/NearestNeighbors/apply(index:outputIndices:outputDistances:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4BNNSO16NearestNeighborsV5apply5index13outputIndices0G9DistancesySiSg_So21BNNSNDArrayDescriptoraALtF"
  },
  "title" : "apply(index:outputIndices:outputDistances:)"
}
-->

# apply(index:outputIndices:outputDistances:)

Calculates the sorted indices and Euclidean distances of the k-nearest neighbors to a specified sample data point.

```
func apply(index: Int?, outputIndices: BNNSNDArrayDescriptor, outputDistances: BNNSNDArrayDescriptor)
```

## Parameters

`index`

The index of the sample data point of which the function computes the k-nearest neighbors.

`outputIndices`

The sorted indices of the k-nearest neighbours to the sample data point.

`outputDistances`

The sorted distances of the k-nearest neighbours to the sample data point.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)