---
title: "init(capacity:dimensionCount:neighborCount:dataType:)"
framework: accelerate
role: symbol
role_heading: Initializer
path: "accelerate/bnns/nearestneighbors/init(capacity:dimensioncount:neighborcount:datatype:)"
---

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

Returns a new k-nearest neighbors object.

## Declaration

```swift
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 doc://com.apple.accelerate/documentation/Accelerate/BNNS/NearestNeighbors/apply(index:outputIndices:outputDistances:) calculates.
- `dataType`: The data type of the data points. This must be either BNNSDataTypeFloat32 or BNNSDataTypeFloat16.
