public class DoubleDistanceDBIDPairKNNListHeap extends Object implements DoubleDistanceKNNList, DoubleDistanceKNNHeap
Modifier and Type | Class and Description |
---|---|
private class |
DoubleDistanceDBIDPairKNNListHeap.Itr
Iterator.
|
Modifier and Type | Field and Description |
---|---|
private DoubleDistanceDBIDPair[] |
data
The actual data array.
|
private int |
k
The value of k this was materialized for.
|
private int |
size
Current size
|
Constructor and Description |
---|
DoubleDistanceDBIDPairKNNListHeap(int k)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the heap.
|
boolean |
contains(DBIDRef o)
Test whether an ID is contained.
|
double |
doubleKNNDistance()
Get the kNN distance as double value.
|
DoubleDistanceDBIDPair |
get(int index)
Direct object access.
|
int |
getK()
Get the K parameter (note: this may be less than the size of the list!)
|
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 dist,
DBIDRef id)
Deprecated.
|
private void |
insertionSort(DoubleDistanceDBIDPair obj)
Perform insertion sort.
|
boolean |
isEmpty()
Test for an empty DBID collection.
|
DoubleDistanceDBIDListIter |
iter()
Get an iterator
|
DoubleDistanceDBIDPair |
peek()
Peek at the largest element in the heap.
|
DoubleDistanceDBIDPair |
poll()
Poll the largest element from the heap.
|
int |
size()
Size
|
DoubleDistanceKNNList |
toKNNList()
Serialize to a
KNNList . |
String |
toString() |
private final int k
private DoubleDistanceDBIDPair[] data
private int size
public DoubleDistanceDBIDPairKNNListHeap(int k)
k
- K parameterpublic void clear()
KNNHeap
clear
in interface KNNHeap<DoubleDistance>
public double insert(double distance, DBIDRef id)
DoubleDistanceKNNHeap
insert
in interface DoubleDistanceKNNHeap
distance
- Distance valueid
- ID number@Deprecated public void insert(Double distance, DBIDRef id)
DoubleDistanceKNNHeap
insert
in interface DoubleDistanceKNNHeap
distance
- Distance valueid
- ID number@Deprecated public void insert(DoubleDistance dist, DBIDRef id)
DoubleDistanceKNNHeap
insert
in interface DoubleDistanceKNNHeap
insert
in interface KNNHeap<DoubleDistance>
dist
- Distance valueid
- ID numberpublic void insert(DoubleDistanceDBIDPair e)
DoubleDistanceKNNHeap
insert
in interface DoubleDistanceKNNHeap
e
- Existing distance pairprivate void insertionSort(DoubleDistanceDBIDPair obj)
obj
- Object to insertpublic DoubleDistanceDBIDPair poll()
KNNHeap
KNNHeap.toKNNList()
.poll
in interface DoubleDistanceKNNHeap
poll
in interface KNNHeap<DoubleDistance>
public DoubleDistanceDBIDPair peek()
KNNHeap
peek
in interface DoubleDistanceKNNHeap
peek
in interface KNNHeap<DoubleDistance>
public DoubleDistanceKNNList toKNNList()
KNNHeap
KNNList
. This empties the heap!toKNNList
in interface DoubleDistanceKNNHeap
toKNNList
in interface KNNHeap<DoubleDistance>
public int getK()
KNNList
getK
in interface KNNHeap<DoubleDistance>
getK
in interface KNNList<DoubleDistance>
@Deprecated public DoubleDistance getKNNDistance()
DoubleDistanceKNNList
getKNNDistance
in interface DoubleDistanceKNNHeap
getKNNDistance
in interface DoubleDistanceKNNList
getKNNDistance
in interface KNNHeap<DoubleDistance>
getKNNDistance
in interface KNNList<DoubleDistance>
public double doubleKNNDistance()
DoubleDistanceKNNList
doubleKNNDistance
in interface DoubleDistanceKNNHeap
doubleKNNDistance
in interface DoubleDistanceKNNList
public DoubleDistanceDBIDPair get(int index)
KNNList
get
in interface DistanceDBIDList<DoubleDistance>
get
in interface DoubleDistanceKNNList
get
in interface KNNList<DoubleDistance>
index
- Offsetpublic DoubleDistanceDBIDListIter iter()
DistanceDBIDList
iter
in interface DBIDs
iter
in interface DistanceDBIDList<DoubleDistance>
iter
in interface DoubleDistanceKNNList
public int size()
KNNList
size
in interface DBIDs
size
in interface DistanceDBIDList<DoubleDistance>
size
in interface KNNHeap<DoubleDistance>
size
in interface KNNList<DoubleDistance>
public boolean contains(DBIDRef o)
DBIDs