public class IncrementalIntKDTree extends Object
int[]
s. Includes
support for range search, neighbour search, and radius search. The tree created
by this class will usually be rather unbalanced.
The KDTree allows fast search for points in relatively low-dimension spaces.
Constructor and Description |
---|
IncrementalIntKDTree()
Create an empty KDTree object
|
IncrementalIntKDTree(Collection<int[]> coords)
Create a KDTree object and populate it with the given data.
|
IncrementalIntKDTree(int[][] coords)
Create a KDTree object and populate it with the given data.
|
Modifier and Type | Method and Description |
---|---|
protected static double |
distance(int[] a,
int[] b) |
ObjectDoublePair<int[]> |
findNearestNeighbour(int[] query)
Find the nearest neighbour.
|
List<ObjectDoublePair<int[]>> |
findNearestNeighbours(int[] query,
int k)
Find the K nearest neighbours.
|
void |
insert(int[] point)
Inserts a point into the tree, preserving the spatial ordering.
|
void |
insertAll(Collection<int[]> coords)
Insert all the points from the given collection into the index.
|
void |
insertAll(int[][] coords)
Insert all the points from the given collection into the index.
|
List<ObjectDoublePair<int[]>> |
radiusDistanceSearch(int[] centre,
int radius)
Find all the points within the given radius of the given point.
|
List<int[]> |
radiusSearch(int[] centre,
int radius)
Find all the points within the given radius of the given point
|
List<int[]> |
rangeSearch(int[] lowerExtreme,
int[] upperExtreme)
Searches the tree for all points contained within the bounding box
defined by the given upper and lower extremes
|
public IncrementalIntKDTree()
public IncrementalIntKDTree(Collection<int[]> coords)
coords
- the data to populate the index with.public IncrementalIntKDTree(int[][] coords)
coords
- the data to populate the index with.public void insertAll(Collection<int[]> coords)
coords
- The points to add.public void insertAll(int[][] coords)
coords
- The points to add.public void insert(int[] point)
point
- Point to insert.public List<int[]> rangeSearch(int[] lowerExtreme, int[] upperExtreme)
lowerExtreme
- upperExtreme
- protected static final double distance(int[] a, int[] b)
public ObjectDoublePair<int[]> findNearestNeighbour(int[] query)
query
- query coordinatepublic List<ObjectDoublePair<int[]>> findNearestNeighbours(int[] query, int k)
query
- query coordinatek
- the number of neighbours to findpublic List<int[]> radiusSearch(int[] centre, int radius)
centre
- the centre pointradius
- the radiuspublic List<ObjectDoublePair<int[]>> radiusDistanceSearch(int[] centre, int radius)
centre
- the centre pointradius
- the radius