Package elki.database.ids.integer
Class IntegerDBIDRange
- java.lang.Object
-
- elki.database.ids.integer.IntegerDBIDRange
-
- All Implemented Interfaces:
DataStoreIDMap
,ArrayDBIDs
,ArrayStaticDBIDs
,DBIDRange
,DBIDs
,IntegerDBIDs
,SetDBIDs
,StaticDBIDs
final class IntegerDBIDRange extends java.lang.Object implements IntegerDBIDs, DBIDRange, SetDBIDs
Representing a DBID range allocation.- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
IntegerDBIDRange.Itr
Iterator in ELKI/C++ style.
-
Constructor Summary
Constructors Modifier Constructor Description protected
IntegerDBIDRange(int start, int len)
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
.int
binarySearch(DBIDRef key)
Search for the position of the given key, assuming that the data set is sorted.boolean
contains(DBIDRef o)
Test whether an ID is contained.DBID
get(int i)
Get the i'th entry (starting at 0)int
getOffset(DBIDRef dbid)
For storage array offsets.IntegerDBIDRange.Itr
iter()
Get a DBID iterator (a more efficient API).int
mapDBIDToOffset(DBIDRef dbid)
Map a DBID to an array offset.int
size()
Retrieve the collection / data size.ArrayDBIDs
slice(int begin, int end)
Slice a subarray (as view, not copy!)java.lang.String
toString()
-
-
-
Method Detail
-
size
public int size()
Description copied from interface:DBIDs
Retrieve the collection / data size.- Specified by:
size
in interfaceArrayDBIDs
- Specified by:
size
in interfaceDBIDs
- Returns:
- collection size
-
contains
public boolean contains(DBIDRef o)
Description copied from interface:DBIDs
Test whether an ID is contained.
-
get
public DBID get(int i)
Description copied from interface:ArrayDBIDs
Get the i'th entry (starting at 0)If possible, use an
DBIDArrayIter
viaArrayDBIDs.iter()
instead, or anDBIDVar
viaArrayDBIDs.assignVar(int, elki.database.ids.DBIDVar)
- Specified by:
get
in interfaceArrayDBIDs
- Parameters:
i
- Index- Returns:
- DBID of i'th entry.
-
getOffset
public int getOffset(DBIDRef dbid)
For storage array offsets.
-
assignVar
public DBIDVar assignVar(int index, DBIDVar var)
Description copied from interface:ArrayDBIDs
Assign a DBID variable the value of positionindex
.- Specified by:
assignVar
in interfaceArrayDBIDs
- Parameters:
index
- Positionvar
- Variable to assign the value to.
-
binarySearch
public int binarySearch(DBIDRef key)
Description copied from interface:ArrayDBIDs
Search for the position of the given key, assuming that the data set is sorted. For unsorted arrays, the result is undefined.For keys not found,
-(1+insertion position)
is returned, as for JavaCollections.binarySearch(java.util.List<? extends java.lang.Comparable<? super T>>, T)
- Specified by:
binarySearch
in interfaceArrayDBIDs
- Parameters:
key
- Key to search for- Returns:
- Offset of key
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
mapDBIDToOffset
public int mapDBIDToOffset(DBIDRef dbid)
Description copied from interface:DataStoreIDMap
Map a DBID to an array offset.- Specified by:
mapDBIDToOffset
in interfaceDataStoreIDMap
- Parameters:
dbid
- DBID- Returns:
- record id
id >= 0
-
slice
public ArrayDBIDs slice(int begin, int end)
Description copied from interface:ArrayDBIDs
Slice a subarray (as view, not copy!)- Specified by:
slice
in interfaceArrayDBIDs
- Parameters:
begin
- Begin (inclusive)end
- End (exclusive)- Returns:
- Array slice.
-
iter
public IntegerDBIDRange.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 interfaceArrayDBIDs
- Specified by:
iter
in interfaceDBIDs
- Specified by:
iter
in interfaceIntegerDBIDs
- Returns:
- iterator
-
-