public class DoubleDistanceIntegerDBIDPairKNNListHeap extends Object implements DoubleDistanceKNNList, DoubleDistanceKNNHeap
Modifier and Type | Class and Description |
---|---|
private class |
DoubleDistanceIntegerDBIDPairKNNListHeap.Itr
Iterator.
|
Modifier and Type | Field and Description |
---|---|
private DoubleDistanceIntegerDBIDPair[] |
data
The actual data array.
|
private int |
k
The value of k this was materialized for.
|
private int |
size
Current size
|
Constructor and Description |
---|
DoubleDistanceIntegerDBIDPairKNNListHeap(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.
|
DoubleDistanceIntegerDBIDPair |
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.
|
private void |
grow() |
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(DoubleDistanceIntegerDBIDPair obj)
Perform insertion sort.
|
boolean |
isEmpty()
Test for an empty DBID collection.
|
DoubleDistanceIntegerDBIDListIter |
iter()
Get an iterator
|
DoubleDistanceIntegerDBIDPair |
peek()
Peek at the largest element in the heap.
|
DoubleDistanceIntegerDBIDPair |
poll()
Poll the largest element from the heap.
|
int |
size()
Size
|
DoubleDistanceKNNList |
toKNNList()
Serialize to a
KNNList . |
String |
toString() |
private void |
truncate() |
private final int k
private DoubleDistanceIntegerDBIDPair[] data
private int size
public DoubleDistanceIntegerDBIDPairKNNListHeap(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 numberprivate void truncate()
@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(DoubleDistanceIntegerDBIDPair obj)
obj
- Object to insertprivate void grow()
public DoubleDistanceIntegerDBIDPair poll()
KNNHeap
KNNHeap.toKNNList()
.poll
in interface DoubleDistanceKNNHeap
poll
in interface KNNHeap<DoubleDistance>
public DoubleDistanceIntegerDBIDPair 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 DoubleDistanceIntegerDBIDPair get(int index)
KNNList
get
in interface DistanceDBIDList<DoubleDistance>
get
in interface DoubleDistanceKNNList
get
in interface KNNList<DoubleDistance>
index
- Offsetpublic DoubleDistanceIntegerDBIDListIter 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