/** * Locate nearest neighbours for a given point in space. * @param nMin number of entries to be returned. More entries may or may not be returned if * several points have the same distance. * @param dist Distance function. Note that the distance function should be compatible * with the preprocessor of the tree. * @param key the center point * @return KNN query iterator. */ public PhKnnQueryF<T> nearestNeighbour(int nMin, PhDistance dist, double... key) { long[] lKey = new long[key.length]; pre.pre(key, lKey); PhKnnQuery<T> iter = pht.nearestNeighbour(nMin, dist, null, lKey); return new PhKnnQueryF<>(iter, pht.getDim(), pre); }
@Override public boolean hasNext() { return iter.hasNext(); }
@Override public PointEntryDist<T> next() { //This reuses the entry object, but we have to clone the arrays... PhEntryDistF<T> e = iter.nextEntryReuse(); return new DistEntryP<>(e.getKey().clone(), e.getValue(), e.dist()); }
/** * Locate nearest neighbours for a given point in space. * @param nMin number of entries to be returned. More entries may or may not be returned if * several points have the same distance. * @param key the center point * @return List of neighbours. */ public PhKnnQueryF<T> nearestNeighbour(int nMin, double... key) { long[] lKey = new long[key.length]; pre.pre(key, lKey); PhKnnQuery<T> iter = pht.nearestNeighbour(nMin, PhDistanceF.THIS, null, lKey); return new PhKnnQueryF<>(iter, pht.getDim(), pre); }
@Override public QueryIteratorKnnPH<T> reset(double[] center, int k) { iter.reset(k, null, center); return this; }