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,
DBID 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, size
getMaxSize, offer
castQueueElement, compare, compareExternal, compareExternalExternal, heapifyDown, heapifyUp, heapifyUpParent, putInQueue, removeAt, swap
add, addAll, element, remove
containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
private 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()
Heap
toSortedArrayList
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()