
| 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.
|
| Modifier | Constructor and Description |
|---|---|
protected |
DoubleIntegerDBIDKNNHeap(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.
|
int |
getK()
Get the K parameter ("maxsize" internally).
|
double |
getKNNDistance()
Get the distance to the k nearest neighbor, or maxdist otherwise.
|
void |
insert(DoubleDBIDPair e)
Add a distance-id pair to the heap unless the distance is too large.
|
double |
insert(double distance,
DBIDRef id)
Add a distance-id pair to the heap unless the distance is too large.
|
boolean |
isEmpty()
Test if the heap is empty.
|
DoubleIntegerDBIDPair |
peek()
Peek at the largest element in the heap.
|
protected double |
peekDistance()
Peek the topmost distance.
|
protected int |
peekInternalDBID()
Peek the topmost internal ID.
|
DoubleIntegerDBIDPair |
poll()
Poll the largest element from the heap.
|
protected void |
pop()
Pop the topmost element.
|
int |
size()
Current size of heap.
|
DoubleIntegerDBIDKNNList |
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
protected DoubleIntegerDBIDKNNHeap(int k)
k - Size of knn.public int getK()
KNNHeappublic double getKNNDistance()
KNNHeapgetKNNDistance in interface KNNHeappublic final double insert(double distance,
DBIDRef id)
KNNHeappublic void insert(DoubleDBIDPair e)
KNNHeapprivate final void updateHeap(double distance,
int iid)
distance - Distanceiid - Object idprivate final void addToTies(int id)
id - Id to addpublic DoubleIntegerDBIDPair poll()
KNNHeapKNNHeap.toKNNList().protected void pop()
public DoubleIntegerDBIDPair peek()
KNNHeappublic int size()
KNNHeappublic boolean isEmpty()
KNNHeappublic void clear()
KNNHeappublic DoubleIntegerDBIDKNNList toKNNList()
KNNHeapKNNList. This empties the heap!protected double peekDistance()
protected int peekInternalDBID()
Copyright © 2015 ELKI Development Team, Lehr- und Forschungseinheit für Datenbanksysteme, Ludwig-Maximilians-Universität München. License information.