Modifier and Type | Class and Description |
---|---|
private class |
DoubleIntegerDBIDKNNHeap.UnorderedIter
Iterate over all objects in the heap, not ordered.
|
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.
|
boolean |
contains(DBIDRef o)
Check if an object is already in 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.
|
protected double |
peekDistance()
Peek the topmost distance.
|
protected int |
peekInternalDBID()
Peek the topmost internal ID.
|
protected void |
pop()
Pop the topmost element.
|
int |
size()
Current size of heap.
|
DoubleIntegerDBIDKNNList |
toKNNList()
Serialize to a
KNNList . |
DoubleIntegerDBIDKNNList |
toKNNListSqrt()
Serialize to a
KNNList , but applying sqrt to every distance. |
DoubleDBIDListIter |
unorderedIterator()
Unordered iterator over the heap.
|
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()
KNNHeap
public double getKNNDistance()
KNNHeap
getKNNDistance
in interface KNNHeap
public final double insert(double distance, DBIDRef id)
KNNHeap
Compared to the super.add() method, this often saves the pair construction.
public void insert(DoubleDBIDPair e)
KNNHeap
Use for existing pairs.
private void updateHeap(double distance, int iid)
distance
- Distanceiid
- Object idprivate void addToTies(int id)
id
- Id to addprotected void pop()
public int size()
KNNHeap
public boolean isEmpty()
KNNHeap
public void clear()
KNNHeap
public DoubleIntegerDBIDKNNList toKNNList()
KNNHeap
KNNList
. This empties the heap!public DoubleIntegerDBIDKNNList toKNNListSqrt()
KNNHeap
KNNList
, but applying sqrt to every distance.
This empties the heap!toKNNListSqrt
in interface KNNHeap
protected double peekDistance()
protected int peekInternalDBID()
public boolean contains(DBIDRef o)
KNNHeap
public DoubleDBIDListIter unorderedIterator()
KNNHeap
unorderedIterator
in interface KNNHeap
Copyright © 2019 ELKI Development Team. License information.