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 classIntegerDBIDKNNSubList.ItrIterator for the sublist.-
Nested classes/interfaces inherited from interface elki.database.ids.DoubleDBIDList
DoubleDBIDList.Consumer
-
-
Field Summary
Fields Modifier and Type Field Description private DoubleIntegerDBIDKNNListinnerWrapped inner result.private intkParameter k.private intsizeActual 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 DBIDVarassignVar(int index, DBIDVar var)Assign a DBID variable the value of positionindex.booleancontains(DBIDRef o)Test whether an ID is contained.doubledoubleValue(int index)Get the double value at a given index (to access the DBID, either useDoubleDBIDList.iter()orDoubleDBIDList.assignVar(int, elki.database.ids.DBIDVar).intgetK()Get the K parameter (note: this may be less than the size of the list!)doublegetKNNDistance()Get the distance to the k nearest neighbor, or infinity otherwise.IntegerDBIDKNNSubList.Itriter()Get a DBID iterator (a more efficient API).KNNListmap(java.util.function.DoubleUnaryOperator f)Function to project the knn list.intsize()Retrieve the collection / data size.KNNListsubList(int k)Select a subset for a smaller k.java.lang.StringtoString()-
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:KNNListGet 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:DoubleDBIDListAssign a DBID variable the value of positionindex.- Specified by:
assignVarin interfaceDoubleDBIDList- Parameters:
index- Positionvar- Variable to assign the value to.
-
doubleValue
public double doubleValue(int index)
Description copied from interface:DoubleDBIDListGet the double value at a given index (to access the DBID, either useDoubleDBIDList.iter()orDoubleDBIDList.assignVar(int, elki.database.ids.DBIDVar).- Specified by:
doubleValuein interfaceDoubleDBIDList- Parameters:
index- Index- Returns:
- Value
-
getKNNDistance
public double getKNNDistance()
Description copied from interface:KNNListGet the distance to the k nearest neighbor, or infinity otherwise.- Specified by:
getKNNDistancein interfaceKNNList- Returns:
- Maximum distance
-
iter
public IntegerDBIDKNNSubList.Itr iter()
Description copied from interface:DBIDsGet 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:
iterin interfaceDBIDs- Specified by:
iterin interfaceDoubleDBIDList- Specified by:
iterin interfaceDoubleIntegerDBIDList- Specified by:
iterin interfaceIntegerDBIDs- Returns:
- iterator
-
contains
public boolean contains(DBIDRef o)
Description copied from interface:DBIDsTest whether an ID is contained.
-
size
public int size()
Description copied from interface:DBIDsRetrieve the collection / data size.- Specified by:
sizein interfaceDBIDs- Specified by:
sizein interfaceDoubleDBIDList- Returns:
- collection size
-
subList
public KNNList subList(int k)
Description copied from interface:KNNListSelect a subset for a smaller k.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-