getNearest method

AnnoyIndexSearchResult getNearest(
  1. Float32List vector,
  2. int nResults, {
  3. int searchK = -1,
  4. bool includeDistance = false,
})

Get nearest items to the given vector

Implementation

AnnoyIndexSearchResult getNearest(Float32List vector, int nResults,
    {int searchK = -1, bool includeDistance = false}) {
  final vecPtr = vector.getPointer();
  try {
    final resultPtr = _factory._getNearest(
        _ptr, vecPtr, nResults, searchK, includeDistance ? 1 : 0);
    try {
      return AnnoyIndexSearchResult._create(
          includeDistance, _factory, resultPtr);
    } finally {
      _factory._freeSearchResult(resultPtr);
    }
  } finally {
    malloc.free(vecPtr);
  }
}