
public class DoubleDistanceIntegerDBIDKNNHeap extends Object implements DoubleDistanceKNNHeap
| Modifier and Type | Field and Description |
|---|---|
private DoubleIntegerMaxHeap |
heap
The main heap.
|
private static int |
INITIAL_TIES_SIZE
Initial size of ties array.
|
private int |
k
k for this heap.
|
private double |
kdist
Current maximum value.
|
private int |
numties
Number of element in ties list.
|
private int[] |
ties
List to track ties.
|
| Constructor and Description |
|---|
DoubleDistanceIntegerDBIDKNNHeap(int k)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
addToTies(int id)
Ensure the ties array has capacity for at least one more element.
|
void |
clear()
Clear the heap.
|
double |
doubleKNNDistance()
Get the distance to the k nearest neighbor, or maxdist otherwise.
|
int |
getK()
Get the K parameter ("maxsize" internally).
|
DoubleDistance |
getKNNDistance()
Deprecated.
|
double |
insert(double distance,
DBIDRef id)
Add a distance-id pair to the heap unless the distance is too large.
|
void |
insert(Double distance,
DBIDRef id)
Deprecated.
|
void |
insert(DoubleDistanceDBIDPair e)
Add a distance-id pair to the heap unless the distance is too large.
|
void |
insert(DoubleDistance distance,
DBIDRef id)
Deprecated.
|
boolean |
isEmpty()
Test if the heap is empty.
|
DoubleDistanceIntegerDBIDPair |
peek()
Peek at the largest element in the heap.
|
protected double |
peekDistance()
Peek the topmost distance.
|
protected int |
peekInternalDBID()
Peek the topmost internal ID.
|
DoubleDistanceIntegerDBIDPair |
poll()
Poll the largest element from the heap.
|
protected void |
pop()
Pop the topmost element.
|
int |
size()
Current size of heap.
|
DoubleDistanceIntegerDBIDKNNList |
toKNNList()
Serialize to a
KNNList. |
private void |
updateHeap(double distance,
int iid)
Do a full update for the heap.
|
private final int k
private final DoubleIntegerMaxHeap heap
private int[] ties
private int numties
private double kdist
private static final int INITIAL_TIES_SIZE
public DoubleDistanceIntegerDBIDKNNHeap(int k)
k - Size of knn.public int getK()
KNNHeapgetK in interface KNNHeap<DoubleDistance>@Deprecated public DoubleDistance getKNNDistance()
DoubleDistanceKNNHeapgetKNNDistance in interface DoubleDistanceKNNHeapgetKNNDistance in interface KNNHeap<DoubleDistance>public double doubleKNNDistance()
DoubleDistanceKNNHeapdoubleKNNDistance in interface DoubleDistanceKNNHeap@Deprecated public void insert(DoubleDistance distance, DBIDRef id)
DoubleDistanceKNNHeapinsert in interface DoubleDistanceKNNHeapinsert in interface KNNHeap<DoubleDistance>distance - Distance valueid - ID number@Deprecated public void insert(Double distance, DBIDRef id)
DoubleDistanceKNNHeapinsert in interface DoubleDistanceKNNHeapdistance - Distance valueid - ID numberpublic final double insert(double distance,
DBIDRef id)
DoubleDistanceKNNHeapinsert in interface DoubleDistanceKNNHeapdistance - Distance valueid - ID numberpublic void insert(DoubleDistanceDBIDPair e)
DoubleDistanceKNNHeapinsert in interface DoubleDistanceKNNHeape - Existing distance pairprivate final void updateHeap(double distance,
int iid)
distance - Distanceiid - Object idprivate final void addToTies(int id)
id - Id to addpublic DoubleDistanceIntegerDBIDPair poll()
KNNHeapKNNHeap.toKNNList().poll in interface DoubleDistanceKNNHeappoll in interface KNNHeap<DoubleDistance>protected void pop()
public DoubleDistanceIntegerDBIDPair peek()
KNNHeappeek in interface DoubleDistanceKNNHeappeek in interface KNNHeap<DoubleDistance>public int size()
KNNHeapsize in interface KNNHeap<DoubleDistance>public boolean isEmpty()
KNNHeapisEmpty in interface KNNHeap<DoubleDistance>public void clear()
KNNHeapclear in interface KNNHeap<DoubleDistance>public DoubleDistanceIntegerDBIDKNNList toKNNList()
KNNHeapKNNList. This empties the heap!toKNNList in interface DoubleDistanceKNNHeaptoKNNList in interface KNNHeap<DoubleDistance>protected double peekDistance()
protected int peekInternalDBID()