V
- The vector typepublic class KDTree<V extends Vec> extends Object implements VectorCollection<V>
VectorArray
can occur.
EuclideanDistance
, ChebyshevDistance
, ManhattanDistance
, MinkowskiDistance
Modifier and Type | Class and Description |
---|---|
static class |
KDTree.KDTreeFactory<V extends Vec> |
static class |
KDTree.PivotSelection
KDTree uses an index of the vector at each stage to use as a pivot,
dividing the remaining elements into two sets.
|
Constructor and Description |
---|
KDTree()
no-arg constructor for serialization
|
KDTree(List<V> vecs,
DistanceMetric distanceMetric)
Creates a new KDTree with the given data and methods.
|
KDTree(List<V> vecs,
DistanceMetric distanceMetric,
KDTree.PivotSelection pvSelection)
Creates a new KDTree with the given data and methods.
|
KDTree(List<V> vecs,
DistanceMetric distanceMetric,
KDTree.PivotSelection pvSelection,
ExecutorService threadpool)
Creates a new KDTree with the given data and methods.
|
Modifier and Type | Method and Description |
---|---|
KDTree<V> |
clone() |
int |
getSplitIndex(List<Integer> data,
int pivot) |
List<? extends VecPaired<V,Double>> |
search(Vec query,
double range)
Searches the space for all vectors that are within a given range of the query vector.
|
List<? extends VecPaired<V,Double>> |
search(Vec query,
int neighbors)
Searches the space for the k neighbors that are closest to the given query vector
|
int |
size()
Returns the number of vectors stored in the collection
|
public KDTree(List<V> vecs, DistanceMetric distanceMetric, KDTree.PivotSelection pvSelection, ExecutorService threadpool)
vecs
- the list of vectors to place in this structuredistanceMetric
- the metric to use for the spacepvSelection
- the method of selection to use for determining what pivot to use.threadpool
- the source of threads to use when constructing. Null is permitted,
in which case a serial construction will occur.public KDTree(List<V> vecs, DistanceMetric distanceMetric, KDTree.PivotSelection pvSelection)
vecs
- the list of vectors to place in this structuredistanceMetric
- the metric to use for the spacepvSelection
- the method of selection to use for determining what pivot to use.public KDTree(List<V> vecs, DistanceMetric distanceMetric)
vecs
- the list of vectors to place in this structuredistanceMetric
- the metric to use for the spacepublic KDTree()
public List<? extends VecPaired<V,Double>> search(Vec query, int neighbors)
VectorCollection
search
in interface VectorCollection<V extends Vec>
query
- the vector we want to find neighbors ofneighbors
- the maximum number of neighbors to returnpublic int size()
VectorCollection
size
in interface VectorCollection<V extends Vec>
public List<? extends VecPaired<V,Double>> search(Vec query, double range)
VectorCollection
search
in interface VectorCollection<V extends Vec>
query
- the vector we want to find others nearrange
- the search range around our queryCopyright © 2017. All rights reserved.