
public class DoubleDistanceDBIDPairKNNHeap extends AbstractKNNHeap<DoubleDistanceDBIDPair,DoubleDistance> implements DoubleDistanceKNNHeap
DBIDUtil.newHeap(D, int)!
 
 Experiments have shown that it can be much more performant to track the
 knndistance outside of the heap, and do comparisons on the stack:
 The reason probably is thatdouble knndist = Double.POSITIVE_INFINITY; DoubleDistanceDBIDPairKNNHeap heap = new DoubleDistanceDBIDPairKNNHeap(k); for (DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { double dist = computeDistance(iditer, ...); if (dist < knndist) { heap.add(dist, iditer); if (heap.size() >= k) { max = heap.doubleKNNDistance(); } } }
knndist resides on the stack and can be
 better optimized by the hotspot compiler.| Modifier and Type | Class and Description | 
|---|---|
protected static class  | 
DoubleDistanceDBIDPairKNNHeap.Comp
Comparator to use. 
 | 
| Modifier and Type | Field and Description | 
|---|---|
static Comparator<DoubleDistanceDBIDPair> | 
COMPARATOR
Comparator class. 
 | 
protected double | 
knndistance
Cached distance to k nearest neighbor (to avoid going through  
AbstractKNNHeap.peek()
 too often). | 
heap| Constructor and Description | 
|---|
DoubleDistanceDBIDPairKNNHeap(int k)
Constructor. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
add(double distance,
   DBIDRef id)
Add a distance-id pair to the heap unless the distance is too large. 
 | 
void | 
add(Double distance,
   DBIDRef id)
Deprecated.  
 | 
void | 
add(DoubleDistanceDBIDPair e)
Add a pair to the heap. 
 | 
void | 
add(DoubleDistance dist,
   DBIDRef id)
Deprecated. 
 
if you know your distances are double-valued, you should be
             using the primitive type. 
 | 
double | 
doubleKNNDistance()
Get the distance to the k nearest neighbor, or maxdist otherwise. 
 | 
DoubleDistance | 
getKNNDistance()
Deprecated. 
 
if you know your distances are double-valued, you should be
             using the primitive type. 
 | 
protected void | 
heapModified()  | 
DoubleDistanceDBIDPairKNNList | 
toKNNList()
Serialize to a  
DoubleDistanceDBIDPairKNNList. | 
clear, getK, isEmpty, peek, poll, sizeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpeek, pollpublic static final Comparator<DoubleDistanceDBIDPair> COMPARATOR
protected double knndistance
AbstractKNNHeap.peek()
 too often).public DoubleDistanceDBIDPairKNNHeap(int k)
DBIDUtil.newHeap(D, int)!k - Heap sizepublic DoubleDistanceDBIDPairKNNList toKNNList()
DoubleDistanceDBIDPairKNNList. This empties the heap!toKNNList in interface DoubleDistanceKNNHeaptoKNNList in interface KNNHeap<DoubleDistance>public final void add(double distance,
       DBIDRef id)
add in interface DoubleDistanceKNNHeapdistance - Distance valueid - ID number@Deprecated public final void add(Double distance, DBIDRef id)
add in interface DoubleDistanceKNNHeapdistance - Distance valueid - ID numberprotected void heapModified()
public void add(DoubleDistanceDBIDPair e)
AbstractKNNHeapadd in interface DoubleDistanceKNNHeapadd in class AbstractKNNHeap<DoubleDistanceDBIDPair,DoubleDistance>e - Pair to add.@Deprecated public void add(DoubleDistance dist, DBIDRef id)
add in interface DoubleDistanceKNNHeapadd in interface KNNHeap<DoubleDistance>dist - Distance valueid - ID numberpublic double doubleKNNDistance()
doubleKNNDistance in interface DoubleDistanceKNNHeap@Deprecated public DoubleDistance getKNNDistance()
getKNNDistance in interface DoubleDistanceKNNHeapgetKNNDistance in interface KNNHeap<DoubleDistance>