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 class
DoubleIntegerDBIDArrayList.Itr
List iterator.-
Nested classes/interfaces inherited from interface elki.database.ids.DoubleDBIDList
DoubleDBIDList.Consumer
-
-
Field Summary
Fields Modifier and Type Field Description (package private) double[]
dists
Distance valuesprivate static double[]
EMPTY_DISTS
Empty.private static int[]
EMPTY_IDS
Empty.(package private) int[]
ids
DBIDsprivate static int
INITIAL_SIZE
Initial size allocation.(package private) int
size
The size
-
Constructor Summary
Constructors Modifier Constructor Description protected
DoubleIntegerDBIDArrayList()
Constructor.protected
DoubleIntegerDBIDArrayList(int size)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(double dist, DBIDRef id)
Add an object to this result.void
add(DoubleDBIDPair pair)
Add an element.protected void
addInternal(double dist, int id)
Add an entry, consisting of distance and internal index.DBIDVar
assignVar(int index, DBIDVar var)
Assign a DBID variable the value of positionindex
.ModifiableDoubleDBIDList
clear()
Clear the list contents.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)
.protected void
grow()
Grow the data storage.DoubleIntegerDBIDArrayList.Itr
iter()
Get a DBID iterator (a more efficient API).void
remove(int index)
Remove the entry at position p by shifting the remainder forward.void
removeSwap(int index)
Remove the entry at position p by swapping with the last (not preserving the order).protected void
reverse()
Reverse the list.int
size()
Retrieve the collection / data size.DoubleIntegerDBIDList
slice(int begin, int end)
Get a subset list.ModifiableDoubleDBIDList
sort()
Sort the result in ascending orderModifiableDoubleDBIDList
sortDescending()
Sort the result in descending ordervoid
swap(int i, int j)
Swap to entries in the list.java.lang.String
toString()
void
truncate(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: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
- Specified by:
iter
in interfaceModifiableDoubleDBIDList
- 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
-
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
-
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:ModifiableDoubleDBIDList
Add an object to this result.- Specified by:
add
in interfaceModifiableDoubleDBIDList
- Parameters:
dist
- Distance to addid
- DBID to add
-
add
public void add(DoubleDBIDPair pair)
Description copied from interface:ModifiableDoubleDBIDList
Add an element.- Specified by:
add
in interfaceModifiableDoubleDBIDList
- Parameters:
pair
- Pair to add
-
clear
public ModifiableDoubleDBIDList clear()
Description copied from interface:ModifiableDoubleDBIDList
Clear the list contents.- Specified by:
clear
in interfaceModifiableDoubleDBIDList
-
sort
public ModifiableDoubleDBIDList sort()
Description copied from interface:ModifiableDoubleDBIDList
Sort the result in ascending order- Specified by:
sort
in interfaceModifiableDoubleDBIDList
- Returns:
- this
-
sortDescending
public ModifiableDoubleDBIDList sortDescending()
Description copied from interface:ModifiableDoubleDBIDList
Sort the result in descending order- Specified by:
sortDescending
in interfaceModifiableDoubleDBIDList
- Returns:
- this
-
reverse
protected void reverse()
Reverse the list.
-
remove
public void remove(int index)
Description copied from interface:ModifiableDoubleDBIDList
Remove the entry at position p by shifting the remainder forward.- Specified by:
remove
in interfaceModifiableDoubleDBIDList
- Parameters:
index
- Entry offset to remove
-
removeSwap
public void removeSwap(int index)
Description copied from interface:ModifiableDoubleDBIDList
Remove the entry at position p by swapping with the last (not preserving the order).- Specified by:
removeSwap
in interfaceModifiableDoubleDBIDList
- Parameters:
index
- Entry offset to remove
-
swap
public void swap(int i, int j)
Description copied from interface:ModifiableDoubleDBIDList
Swap to entries in the list.- Specified by:
swap
in 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:DoubleDBIDList
Get a subset list.- Specified by:
slice
in interfaceDoubleDBIDList
- Specified by:
slice
in interfaceDoubleIntegerDBIDList
- Parameters:
begin
- Beginend
- End- Returns:
- Sublist
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-