public class LongKDTree extends Object
LongKDTree.SplitChooser
. Supports efficient range, radius and
nearest-neighbour search for relatively low dimensional spaces.Modifier and Type | Class and Description |
---|---|
static class |
LongKDTree.ApproximateBBFMedianSplit
Approximate best-bin-first median splitting.
|
static class |
LongKDTree.BasicMedianSplit
Basic median split.
|
static class |
LongKDTree.BBFMedianSplit
Best-bin-first median splitting.
|
static class |
LongKDTree.KDTreeNode
An internal node of the KDTree
|
static class |
LongKDTree.RandomisedBBFMeanSplit
Randomised best-bin-first splitting strategy:
Nodes with less than a set number of items become leafs.
|
static interface |
LongKDTree.SplitChooser
Interface for describing how a branch in the KD-Tree should be created
|
Modifier and Type | Field and Description |
---|---|
long[][] |
data
The underlying data array
|
LongKDTree.KDTreeNode |
root
The tree roots
|
Constructor and Description |
---|
LongKDTree(long[][] data)
Construct with the given data and default splitting strategy (
LongKDTree.BBFMedianSplit ) |
LongKDTree(long[][] data,
LongKDTree.SplitChooser split)
Construct with the given data and splitting strategy
|
Modifier and Type | Method and Description |
---|---|
long[][] |
coordinateRadiusSearch(long[] centre,
long radius)
Find all the points within the given radius of the given point.
|
void |
coordinateRadiusSearch(long[] centre,
long radius,
gnu.trove.procedure.TObjectDoubleProcedure<long[]> proc)
Find all the points within the given radius of the given point.
|
long[][] |
coordinateRangeSearch(long[] lowerExtreme,
long[] upperExtreme)
Search the tree for all points contained within the hyperrectangle
defined by the given upper and lower extremes.
|
int[] |
indexRadiusSearch(long[] centre,
long radius)
Search the tree for the indexes of all points contained within the
hypersphere defined by the given centre and radius.
|
int[] |
indexRangeSearch(long[] lowerExtreme,
long[] upperExtreme)
Search the tree for all points contained within the hyperrectangle
defined by the given upper and lower extremes.
|
List<int[]> |
leafIndices()
Find all the indices seperated by leaves
|
IntDoublePair |
nearestNeighbour(long[] qu)
Nearest-neighbour search
|
List<IntDoublePair> |
nearestNeighbours(long[] qu,
int n)
Nearest-neighbour search
|
void |
radiusSearch(long[] centre,
long radius,
gnu.trove.procedure.TIntObjectProcedure<long[]> proc)
Find all the points within the given radius of the given point.
|
void |
rangeSearch(long[] lowerExtreme,
long[] upperExtreme,
gnu.trove.procedure.TIntObjectProcedure<long[]> proc)
Search the tree for all points contained within the hyperrectangle
defined by the given upper and lower extremes.
|
public final LongKDTree.KDTreeNode root
public final long[][] data
public LongKDTree(long[][] data)
LongKDTree.BBFMedianSplit
)data
- the datapublic LongKDTree(long[][] data, LongKDTree.SplitChooser split)
data
- the datasplit
- the splitting strategypublic long[][] coordinateRangeSearch(long[] lowerExtreme, long[] upperExtreme)
lowerExtreme
- the lower extreme of the hyperrectangleupperExtreme
- the upper extreme of the hyperrectanglepublic int[] indexRangeSearch(long[] lowerExtreme, long[] upperExtreme)
lowerExtreme
- the lower extreme of the hyperrectangleupperExtreme
- the upper extreme of the hyperrectanglepublic int[] indexRadiusSearch(long[] centre, long radius)
centre
- the centre pointradius
- the radiuspublic void radiusSearch(long[] centre, long radius, gnu.trove.procedure.TIntObjectProcedure<long[]> proc)
The search can be stopped early by returning false from the
TIntObjectProcedure.execute(int, Object)
method.
centre
- the centre pointradius
- the radiusproc
- the processpublic void rangeSearch(long[] lowerExtreme, long[] upperExtreme, gnu.trove.procedure.TIntObjectProcedure<long[]> proc)
The search can be stopped early by returning false from the
TIntObjectProcedure.execute(int, Object)
method.
lowerExtreme
- the lower extreme of the hyperrectangleupperExtreme
- the upper extreme of the hyperrectangleproc
- the processorpublic List<IntDoublePair> nearestNeighbours(long[] qu, int n)
qu
- the query pointn
- the number of neighbours to findpublic IntDoublePair nearestNeighbour(long[] qu)
qu
- the query pointpublic long[][] coordinateRadiusSearch(long[] centre, long radius)
centre
- the centre pointradius
- the radiuspublic void coordinateRadiusSearch(long[] centre, long radius, gnu.trove.procedure.TObjectDoubleProcedure<long[]> proc)
The search can be stopped early by returning false from the
TIntObjectProcedure.execute(int, Object)
method.
centre
- the centre pointradius
- the radiusproc
- the processpublic List<int[]> leafIndices()