Package elki.database.ids.integer
Class IntegerDBIDKNNSubList
- java.lang.Object
-
- elki.database.ids.integer.IntegerDBIDKNNSubList
-
- All Implemented Interfaces:
DBIDs
,DoubleDBIDList
,DoubleIntegerDBIDList
,IntegerDBIDs
,KNNList
public class IntegerDBIDKNNSubList extends java.lang.Object implements KNNList, DoubleIntegerDBIDList
Sublist of an existing result to contain only the first k elements.- Since:
- 0.7.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
IntegerDBIDKNNSubList.Itr
Iterator for the sublist.-
Nested classes/interfaces inherited from interface elki.database.ids.DoubleDBIDList
DoubleDBIDList.Consumer
-
-
Field Summary
Fields Modifier and Type Field Description private DoubleIntegerDBIDKNNList
inner
Wrapped inner result.private int
k
Parameter k.private int
size
Actual size, including ties.
-
Constructor Summary
Constructors Constructor Description IntegerDBIDKNNSubList(DoubleIntegerDBIDKNNList inner, int k)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DBIDVar
assignVar(int index, DBIDVar var)
Assign a DBID variable the value of positionindex
.boolean
contains(DBIDRef o)
Test whether an ID is contained.double
doubleValue(int index)
Get the double value at a given index (to access the DBID, either useDoubleDBIDList.iter()
orDoubleDBIDList.assignVar(int, elki.database.ids.DBIDVar)
.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 infinity otherwise.IntegerDBIDKNNSubList.Itr
iter()
Get a DBID iterator (a more efficient API).KNNList
map(java.util.function.DoubleUnaryOperator f)
Function to project the knn list.int
size()
Retrieve the collection / data size.KNNList
subList(int k)
Select a subset for a smaller k.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface elki.database.ids.DoubleDBIDList
forEachDouble
-
Methods inherited from interface elki.database.ids.integer.DoubleIntegerDBIDList
slice
-
-
-
-
Field Detail
-
k
private final int k
Parameter k.
-
size
private final int size
Actual size, including ties.
-
inner
private final DoubleIntegerDBIDKNNList inner
Wrapped inner result.
-
-
Constructor Detail
-
IntegerDBIDKNNSubList
public IntegerDBIDKNNSubList(DoubleIntegerDBIDKNNList inner, int k)
Constructor.- Parameters:
inner
- Inner instancek
- k value
-
-
Method Detail
-
getK
public int getK()
Description copied from interface:KNNList
Get the K parameter (note: this may be less than the size of the list!)
-
assignVar
public DBIDVar assignVar(int index, DBIDVar var)
Description copied from interface:DoubleDBIDList
Assign a DBID variable the value of positionindex
.- Specified by:
assignVar
in interfaceDoubleDBIDList
- Parameters:
index
- Positionvar
- Variable to assign the value to.
-
doubleValue
public double doubleValue(int index)
Description copied from interface:DoubleDBIDList
Get the double value at a given index (to access the DBID, either useDoubleDBIDList.iter()
orDoubleDBIDList.assignVar(int, elki.database.ids.DBIDVar)
.- Specified by:
doubleValue
in interfaceDoubleDBIDList
- Parameters:
index
- Index- Returns:
- Value
-
getKNNDistance
public double getKNNDistance()
Description copied from interface:KNNList
Get the distance to the k nearest neighbor, or infinity otherwise.- Specified by:
getKNNDistance
in interfaceKNNList
- Returns:
- Maximum distance
-
iter
public IntegerDBIDKNNSubList.Itr iter()
Description copied from interface:DBIDs
Get a DBID iterator (a more efficient API).Example:
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { NumberVector vec = relation.get(iter); // iter is a temporary object reference }
- Specified by:
iter
in interfaceDBIDs
- Specified by:
iter
in interfaceDoubleDBIDList
- Specified by:
iter
in interfaceDoubleIntegerDBIDList
- Specified by:
iter
in interfaceIntegerDBIDs
- Returns:
- iterator
-
contains
public boolean contains(DBIDRef o)
Description copied from interface:DBIDs
Test whether an ID is contained.
-
size
public int size()
Description copied from interface:DBIDs
Retrieve the collection / data size.- Specified by:
size
in interfaceDBIDs
- Specified by:
size
in interfaceDoubleDBIDList
- Returns:
- collection size
-
subList
public KNNList subList(int k)
Description copied from interface:KNNList
Select a subset for a smaller k.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-