class DoubleIntegerDBIDPairKNNListHeap extends Object implements IntegerDBIDKNNList, KNNHeap
Modifier and Type | Class and Description |
---|---|
private class |
DoubleIntegerDBIDPairKNNListHeap.Itr
Iterator.
|
Modifier and Type | Field and Description |
---|---|
private DoubleIntegerDBIDPair[] |
data
The actual data array.
|
private int |
k
The value of k this was materialized for.
|
private int |
size
Current size
|
Modifier | Constructor and Description |
---|---|
protected |
DoubleIntegerDBIDPairKNNListHeap(int k)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the heap.
|
boolean |
contains(DBIDRef o)
Test whether an ID is contained.
|
DoubleIntegerDBIDPair |
get(int index)
Direct object access.
|
int |
getK()
Get the K parameter (note: this may be less than the size of the list!)
|
double |
getKNNDistance()
Get the distance to the k nearest neighbor, or maxdist otherwise.
|
private void |
grow() |
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.
|
private void |
insertionSort(DoubleIntegerDBIDPair obj)
Perform insertion sort.
|
boolean |
isEmpty()
Test for an empty DBID collection.
|
DoubleIntegerDBIDPairKNNListHeap.Itr |
iter()
Get a DBID iterator (a more efficient API).
|
DoubleIntegerDBIDPair |
peek()
Peek at the largest element in the heap.
|
DoubleIntegerDBIDPair |
poll()
Poll the largest element from the heap.
|
int |
size()
Size
|
KNNList |
toKNNList()
Serialize to a
KNNList . |
String |
toString() |
private void |
truncate() |
private final int k
private DoubleIntegerDBIDPair[] data
private int size
protected DoubleIntegerDBIDPairKNNListHeap(int k)
k
- K parameterpublic void clear()
KNNHeap
public double insert(double distance, DBIDRef id)
KNNHeap
private void truncate()
public void insert(DoubleDBIDPair e)
KNNHeap
private void insertionSort(DoubleIntegerDBIDPair obj)
obj
- Object to insertprivate void grow()
public DoubleIntegerDBIDPair poll()
KNNHeap
KNNHeap.toKNNList()
.public DoubleIntegerDBIDPair peek()
KNNHeap
public KNNList toKNNList()
KNNHeap
KNNList
. This empties the heap!public int getK()
KNNList
public double getKNNDistance()
KNNList
getKNNDistance
in interface KNNHeap
getKNNDistance
in interface KNNList
public DoubleIntegerDBIDPair get(int index)
KNNList
get
in interface DoubleDBIDList
get
in interface IntegerDBIDKNNList
get
in interface KNNList
index
- Offsetpublic DoubleIntegerDBIDPairKNNListHeap.Itr iter()
DBIDs
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
DBID id = iter.getDBID();
}
iter
in interface DBIDs
iter
in interface DoubleDBIDList
iter
in interface IntegerDBIDKNNList
iter
in interface IntegerDBIDs
public int size()
KNNList
public boolean contains(DBIDRef o)
DBIDs
Copyright © 2015 ELKI Development Team, Lehr- und Forschungseinheit für Datenbanksysteme, Ludwig-Maximilians-Universität München. License information.