
D - distance typepublic class KNNHeap<D extends Distance<D>> extends TiedTopBoundedHeap<DistanceResultPair<D>>
| Modifier and Type | Class and Description |
|---|---|
static class |
KNNHeap.Comp<D extends Distance<D>>
Comparator to use.
|
| Modifier and Type | Field and Description |
|---|---|
private D |
maxdist
Maximum distance, usually infiniteDistance
|
private static long |
serialVersionUID
Serial version
|
maxsize| Constructor and Description |
|---|
KNNHeap(int k)
Simplified constructor.
|
KNNHeap(int k,
D maxdist)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(D distance,
DBIDRef id)
Add a distance-id pair to the heap unless the distance is too large.
|
int |
getK()
Get the K parameter ("maxsize" internally).
|
D |
getKNNDistance()
Get the distance to the k nearest neighbor, or maxdist otherwise.
|
D |
getMaximumDistance()
Get maximum distance in heap
|
KNNList<D> |
toKNNList()
Serialize to a
KNNList. |
ArrayList<DistanceResultPair<D>> |
toSortedArrayList()
Return the heap as a sorted array list, by repeated polling.
|
clear, contains, handleOverflow, iterator, peek, poll, sizegetMaxSize, offeradd, addAll, castQueueElement, checkHeap, ensureValid, heapifyDown, heapifyDownComparable, heapifyDownComparator, heapifyUp, heapifyUpComparable, heapifyUpComparator, removeAt, resizeelement, removecontainsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcontainsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArrayprivate static final long serialVersionUID
public KNNHeap(int k,
D maxdist)
k - k Parametermaxdist - k-distance to return for less than k neighbors - usually
infiniteDistancepublic KNNHeap(int k)
null as kNN distance with less
than k entries.k - k Parameterpublic ArrayList<DistanceResultPair<D>> toSortedArrayList()
HeaptoSortedArrayList in class Heap<DistanceResultPair<D extends Distance<D>>>public KNNList<D> toKNNList()
KNNList. This empties the heap!public int getK()
public D getKNNDistance()
public D getMaximumDistance()