<!--
{
  "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/init(capacity:dimensionCount:neighborCount:dataType:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4BNNSO16NearestNeighborsV8capacity14dimensionCount08neighborG08dataTypeAESi_S2iSo08BNNSDataJ0atcfc"
  },
  "title" : "init(capacity:dimensionCount:neighborCount:dataType:)"
}
-->

# init(capacity:dimensionCount:neighborCount:dataType:)

Returns a new k-nearest neighbors object.

```
init(capacity: Int, dimensionCount: Int, neighborCount: Int, dataType: BNNSDataType)
```

## Parameters

`capacity`

The maximum number of data points.

`dimensionCount`

The number of features or dimensions of each data point.

`neighborCount`

The number of nearest neighbors that a subsequent call to [`apply(index:outputIndices:outputDistances:)`](/documentation/Accelerate/BNNS/NearestNeighbors/apply(index:outputIndices:outputDistances:)) calculates.

`dataType`

The data type of the data points. This must be either `BNNSDataTypeFloat32` or `BNNSDataTypeFloat16`.

---

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)