public class NearestNeighborsSearch<T> extends ArrayList<DistanceComparable<T>> implements INearestNeighborsSearch<T>
TreeSet
)Modifier and Type | Field and Description |
---|---|
protected IDistanceFunction<T> |
distanceFunction |
protected static Logger |
logger |
protected boolean |
lowestDistanceIsClosest |
modCount
Constructor and Description |
---|
NearestNeighborsSearch() |
NearestNeighborsSearch(IDistanceFunction<T> distanceFunction) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(DistanceComparable<T> o) |
boolean |
addObject(T o)
null property
|
boolean |
addObject(T o,
Object property) |
IDistanceFunction<T> |
getDistanceFunction() |
List<DistanceComparable<T>> |
getNearestNeighbors(T query,
int k)
Returns k nearest neighbors, encapsulated in
DistanceComparable . |
boolean |
isLowestDistanceIsClosest() |
void |
setDistanceFunction(IDistanceFunction<T> distanceFunction) |
void |
setLowestDistanceIsClosest(boolean lowestDistanceIsClosest) |
add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
equals, hashCode
containsAll, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
containsAll, equals, hashCode
parallelStream, stream
protected IDistanceFunction<T> distanceFunction
protected boolean lowestDistanceIsClosest
protected static Logger logger
public NearestNeighborsSearch()
public NearestNeighborsSearch(IDistanceFunction<T> distanceFunction)
public boolean add(DistanceComparable<T> o)
add
in interface Collection<DistanceComparable<T>>
add
in interface List<DistanceComparable<T>>
add
in class ArrayList<DistanceComparable<T>>
public boolean addObject(T o)
o
- Objectpublic boolean addObject(T o, Object property)
o
- Objectproperty
- property to be predictedpublic List<DistanceComparable<T>> getNearestNeighbors(T query, int k) throws Exception
DistanceComparable
.
The closest neighbors come first.getNearestNeighbors
in interface INearestNeighborsSearch<T>
Exception
public IDistanceFunction<T> getDistanceFunction()
getDistanceFunction
in interface INearestNeighborsSearch<T>
public void setDistanceFunction(IDistanceFunction<T> distanceFunction)
setDistanceFunction
in interface INearestNeighborsSearch<T>
public boolean isLowestDistanceIsClosest()
public void setLowestDistanceIsClosest(boolean lowestDistanceIsClosest)
Copyright © 2004–2020 Ideaconsult Ltd.. All rights reserved.