public class IncrementalLongKDTree extends Object
long[]
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 |
---|
IncrementalLongKDTree()
Create an empty KDTree object
|
IncrementalLongKDTree(Collection<long[]> coords)
Create a KDTree object and populate it with the given data.
|
IncrementalLongKDTree(long[][] coords)
Create a KDTree object and populate it with the given data.
|
Modifier and Type | Method and Description |
---|---|
protected static double |
distance(long[] a,
long[] b) |
ObjectDoublePair<long[]> |
findNearestNeighbour(long[] query)
Find the nearest neighbour.
|
List<ObjectDoublePair<long[]>> |
findNearestNeighbours(long[] query,
int k)
Find the K nearest neighbours.
|
void |
insert(long[] point)
Inserts a point into the tree, preserving the spatial ordering.
|
void |
insertAll(Collection<long[]> coords)
Insert all the points from the given collection into the index.
|
void |
insertAll(long[][] coords)
Insert all the points from the given collection into the index.
|
List<ObjectDoublePair<long[]>> |
radiusDistanceSearch(long[] centre,
long radius)
Find all the points within the given radius of the given point.
|
List<long[]> |
radiusSearch(long[] centre,
long radius)
Find all the points within the given radius of the given point
|
List<long[]> |
rangeSearch(long[] lowerExtreme,
long[] upperExtreme)
Searches the tree for all points contained within the bounding box
defined by the given upper and lower extremes
|
public IncrementalLongKDTree()
public IncrementalLongKDTree(Collection<long[]> coords)
coords
- the data to populate the index with.public IncrementalLongKDTree(long[][] coords)
coords
- the data to populate the index with.public void insertAll(Collection<long[]> coords)
coords
- The points to add.public void insertAll(long[][] coords)
coords
- The points to add.public void insert(long[] point)
point
- Point to insert.public List<long[]> rangeSearch(long[] lowerExtreme, long[] upperExtreme)
lowerExtreme
- upperExtreme
- protected static final double distance(long[] a, long[] b)
public ObjectDoublePair<long[]> findNearestNeighbour(long[] query)
query
- query coordinatepublic List<ObjectDoublePair<long[]>> findNearestNeighbours(long[] query, int k)
query
- query coordinatek
- the number of neighbours to findpublic List<long[]> radiusSearch(long[] centre, long radius)
centre
- the centre pointradius
- the radiuspublic List<ObjectDoublePair<long[]>> radiusDistanceSearch(long[] centre, long radius)
centre
- the centre pointradius
- the radius