getNearestToItem method

AnnoyIndexSearchResult getNearestToItem(
  1. int itemId,
  2. int nResults, {
  3. int searchK = -1,
  4. bool includeDistance = false,
})

Get nearest items to the given item id

Implementation

AnnoyIndexSearchResult getNearestToItem(int itemId, int nResults,
    {int searchK = -1, bool includeDistance = false}) {
  final resultPtr = _factory._getNearestToItem(
      _ptr, itemId, nResults, searchK, includeDistance ? 1 : 0);
  try {
    return AnnoyIndexSearchResult._create(
        includeDistance, _factory, resultPtr);
  } finally {
    _factory._freeSearchResult(resultPtr);
  }
}