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()
KNNHeap
getK
in interface KNNHeap<DoubleDistance>
@Deprecated public DoubleDistance getKNNDistance()
DoubleDistanceKNNHeap
getKNNDistance
in interface DoubleDistanceKNNHeap
getKNNDistance
in interface KNNHeap<DoubleDistance>
public double doubleKNNDistance()
DoubleDistanceKNNHeap
doubleKNNDistance
in interface DoubleDistanceKNNHeap
@Deprecated public void insert(DoubleDistance distance, DBIDRef id)
DoubleDistanceKNNHeap
insert
in interface DoubleDistanceKNNHeap
insert
in interface KNNHeap<DoubleDistance>
distance
- Distance valueid
- ID number@Deprecated public void insert(Double distance, DBIDRef id)
DoubleDistanceKNNHeap
insert
in interface DoubleDistanceKNNHeap
distance
- Distance valueid
- ID numberpublic final double insert(double distance, DBIDRef id)
DoubleDistanceKNNHeap
insert
in interface DoubleDistanceKNNHeap
distance
- Distance valueid
- ID numberpublic void insert(DoubleDistanceDBIDPair e)
DoubleDistanceKNNHeap
insert
in interface DoubleDistanceKNNHeap
e
- 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()
KNNHeap
KNNHeap.toKNNList()
.poll
in interface DoubleDistanceKNNHeap
poll
in interface KNNHeap<DoubleDistance>
protected void pop()
public DoubleDistanceIntegerDBIDPair peek()
KNNHeap
peek
in interface DoubleDistanceKNNHeap
peek
in interface KNNHeap<DoubleDistance>
public int size()
KNNHeap
size
in interface KNNHeap<DoubleDistance>
public boolean isEmpty()
KNNHeap
isEmpty
in interface KNNHeap<DoubleDistance>
public void clear()
KNNHeap
clear
in interface KNNHeap<DoubleDistance>
public DoubleDistanceIntegerDBIDKNNList toKNNList()
KNNHeap
KNNList
. This empties the heap!toKNNList
in interface DoubleDistanceKNNHeap
toKNNList
in interface KNNHeap<DoubleDistance>
protected double peekDistance()
protected int peekInternalDBID()