Package elki.database.ids.integer
Class DoubleIntegerDBIDArrayList
- java.lang.Object
-
- elki.database.ids.integer.DoubleIntegerDBIDArrayList
-
- All Implemented Interfaces:
DBIDs,DoubleDBIDList,DoubleIntegerDBIDList,IntegerDBIDs,ModifiableDoubleDBIDList
- Direct Known Subclasses:
DoubleIntegerDBIDKNNList
class DoubleIntegerDBIDArrayList extends java.lang.Object implements ModifiableDoubleDBIDList, DoubleIntegerDBIDList
Class to store double distance, integer DBID results.- Since:
- 0.6.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classDoubleIntegerDBIDArrayList.ItrList iterator.-
Nested classes/interfaces inherited from interface elki.database.ids.DoubleDBIDList
DoubleDBIDList.Consumer
-
-
Field Summary
Fields Modifier and Type Field Description (package private) double[]distsDistance valuesprivate static double[]EMPTY_DISTSEmpty.private static int[]EMPTY_IDSEmpty.(package private) int[]idsDBIDsprivate static intINITIAL_SIZEInitial size allocation.(package private) intsizeThe size
-
Constructor Summary
Constructors Modifier Constructor Description protectedDoubleIntegerDBIDArrayList()Constructor.protectedDoubleIntegerDBIDArrayList(int size)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(double dist, DBIDRef id)Add an object to this result.voidadd(DoubleDBIDPair pair)Add an element.protected voidaddInternal(double dist, int id)Add an entry, consisting of distance and internal index.DBIDVarassignVar(int index, DBIDVar var)Assign a DBID variable the value of positionindex.ModifiableDoubleDBIDListclear()Clear the list contents.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).protected voidgrow()Grow the data storage.DoubleIntegerDBIDArrayList.Itriter()Get a DBID iterator (a more efficient API).voidremove(int index)Remove the entry at position p by shifting the remainder forward.voidremoveSwap(int index)Remove the entry at position p by swapping with the last (not preserving the order).protected voidreverse()Reverse the list.intsize()Retrieve the collection / data size.DoubleIntegerDBIDListslice(int begin, int end)Get a subset list.ModifiableDoubleDBIDListsort()Sort the result in ascending orderModifiableDoubleDBIDListsortDescending()Sort the result in descending ordervoidswap(int i, int j)Swap to entries in the list.java.lang.StringtoString()voidtruncate(int newsize)Truncate the list to the given size, freeing the memory.-
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
-
-
-
-
Field Detail
-
INITIAL_SIZE
private static final int INITIAL_SIZE
Initial size allocation.- See Also:
- Constant Field Values
-
size
int size
The size
-
dists
double[] dists
Distance values
-
ids
int[] ids
DBIDs
-
EMPTY_DISTS
private static final double[] EMPTY_DISTS
Empty.
-
EMPTY_IDS
private static final int[] EMPTY_IDS
Empty.
-
-
Method Detail
-
iter
public DoubleIntegerDBIDArrayList.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- Specified by:
iterin interfaceModifiableDoubleDBIDList- 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
-
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
-
addInternal
protected void addInternal(double dist, int id)Add an entry, consisting of distance and internal index.- Parameters:
dist- Distanceid- Internal index
-
grow
protected void grow()
Grow the data storage.
-
add
public void add(double dist, DBIDRef id)Description copied from interface:ModifiableDoubleDBIDListAdd an object to this result.- Specified by:
addin interfaceModifiableDoubleDBIDList- Parameters:
dist- Distance to addid- DBID to add
-
add
public void add(DoubleDBIDPair pair)
Description copied from interface:ModifiableDoubleDBIDListAdd an element.- Specified by:
addin interfaceModifiableDoubleDBIDList- Parameters:
pair- Pair to add
-
clear
public ModifiableDoubleDBIDList clear()
Description copied from interface:ModifiableDoubleDBIDListClear the list contents.- Specified by:
clearin interfaceModifiableDoubleDBIDList
-
sort
public ModifiableDoubleDBIDList sort()
Description copied from interface:ModifiableDoubleDBIDListSort the result in ascending order- Specified by:
sortin interfaceModifiableDoubleDBIDList- Returns:
- this
-
sortDescending
public ModifiableDoubleDBIDList sortDescending()
Description copied from interface:ModifiableDoubleDBIDListSort the result in descending order- Specified by:
sortDescendingin interfaceModifiableDoubleDBIDList- Returns:
- this
-
reverse
protected void reverse()
Reverse the list.
-
remove
public void remove(int index)
Description copied from interface:ModifiableDoubleDBIDListRemove the entry at position p by shifting the remainder forward.- Specified by:
removein interfaceModifiableDoubleDBIDList- Parameters:
index- Entry offset to remove
-
removeSwap
public void removeSwap(int index)
Description copied from interface:ModifiableDoubleDBIDListRemove the entry at position p by swapping with the last (not preserving the order).- Specified by:
removeSwapin interfaceModifiableDoubleDBIDList- Parameters:
index- Entry offset to remove
-
swap
public void swap(int i, int j)Description copied from interface:ModifiableDoubleDBIDListSwap to entries in the list.- Specified by:
swapin interfaceModifiableDoubleDBIDList- Parameters:
i- First entryj- Second entry
-
truncate
public void truncate(int newsize)
Truncate the list to the given size, freeing the memory.- Parameters:
newsize- New size
-
slice
public DoubleIntegerDBIDList slice(int begin, int end)
Description copied from interface:DoubleDBIDListGet a subset list.- Specified by:
slicein interfaceDoubleDBIDList- Specified by:
slicein interfaceDoubleIntegerDBIDList- Parameters:
begin- Beginend- End- Returns:
- Sublist
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-