/** * @return PH-Tree statistics */ public PhTreeStats getStats() { return pht.getStats(); }
/** * @return A string tree view of all entries in the tree. * @see PhTree#toStringTree() */ public String toStringTree() { return pht.toStringTree(); }
/** * Clear the tree. */ public void clear() { pht.clear(); }
/** * 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 int getDIM() { return tree.getDim(); }
/** * @return an iterator over all elements in the tree */ public PhExtentF<T> queryExtent() { return new PhExtentF<>(pht.queryExtent(), pht.getDim(), pre); }
/** * Performs a rectangular window query. The parameters are the min and max keys which * contain the minimum respectively the maximum keys in every dimension. * @param min Minimum values * @param max Maximum values * @return Result iterator. */ public PhQueryF<T> query(double[] min, double[] max) { long[] lMin = new long[min.length]; long[] lMax = new long[max.length]; pre.pre(min, lMin); pre.pre(max, lMax); return new PhQueryF<>(pht.query(lMin, lMax), pht.getDim(), pre); }
/** * Create a new tree with the specified number of dimensions. * * @param dim number of dimensions */ private PhTreeSolid(int dim) { this(PhTree.create(dim*2)); }
@Override public boolean contains(long... key) { return tree.contains(key); }
@Override public boolean insert(long... key) { return tree.put(key, VALUE_PLACEHOLDER) != null; }
/** * @param key the key * @return the value associated with the key or 'null' if the key was not found */ public T get(double ... key) { long[] lKey = new long[key.length]; pre.pre(key, lKey); return pht.get(lKey); }
@Override public int getDEPTH() { return tree.getBitDepth(); }
/** * 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 distanceFunction A distance function for rectangle data. This parameter is optional, * passing a {@code null} will use the default distance function. * @param center the center point * @return The query iterator. */ public PhKnnQuerySF<T> nearestNeighbour(int nMin, PhDistanceSF distanceFunction, double ... center) { long[] lCenter = new long[2*dims]; pre.pre(center, center, lCenter); PhDistanceSF df = distanceFunction == null ? dist : distanceFunction; return new PhKnnQuerySF<>(pht.nearestNeighbour(nMin, df, null, lCenter), dims, pre); }
/** * 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); }
public PhRangeQuery(PhQuery<T> iter, PhTree<T> tree, PhDistance dist, PhFilterDistance filter) { this.dims = tree.getDim(); this.q = iter; this.dist = dist; this.filter = filter; this.min = new long[dims]; this.max = new long[dims]; }
/** * Create a new tree with the specified number of dimensions. * * @param dim number of dimensions */ protected PhTreeSolidF(int dim) { this(PhTree.create(dim*2)); }
/** * @param key key * @return true if the key exists in the tree */ public boolean contains(double ... key) { long[] lKey = new long[key.length]; pre.pre(key, lKey); return pht.contains(lKey); }
/** * Insert an entry associated with a k dimensional key. * @param key the key to store the value to store * @param value the value * @return the previously associated value or {@code null} if the key was found */ public T put(double[] key, T value) { long[] lKey = new long[key.length]; pre.pre(key, lKey); return pht.put(lKey, value); }
/** * @param lower min value * @param upper max value * @return the element that has 'upper' and 'lower' as key. */ public T get(double[] lower, double[] upper) { long[] lVal = new long[lower.length*2]; pre.pre(lower, upper, lVal); return pht.get(lVal); }
public PhTreeStats getStats() { return pht.getStats(); } }