final class IntegerDBID extends Object implements DBID, IntegerDBIDRef
long
, it should not require
changes in too many places!)
In particular, a developer should not make any assumption of these IDs being
consistent across multiple results/databases.Modifier and Type | Class and Description |
---|---|
protected class |
IntegerDBID.DBIDItr
Pseudo iterator for DBIDs interface.
|
static class |
IntegerDBID.DynamicSerializer
Dynamic sized serializer, using varint.
|
static class |
IntegerDBID.StaticSerializer
Static sized serializer, using regular integers.
|
Modifier and Type | Field and Description |
---|---|
static ByteBufferSerializer<DBID> |
DYNAMIC_SERIALIZER
The public instance to use for dynamic serialization.
|
protected int |
id
The actual object ID.
|
static FixedSizeByteBufferSerializer<DBID> |
STATIC_SERIALIZER
The public instance to use for static serialization.
|
Modifier | Constructor and Description |
---|---|
protected |
IntegerDBID(int id)
Constructor from integer id.
|
protected |
IntegerDBID(Integer id)
Constructor from integer id.
|
Modifier and Type | Method and Description |
---|---|
void |
assign(int index,
DBIDVar var)
Assign a DBID variable the value of position
index . |
int |
binarySearch(DBIDRef key)
Search for the position of the given key, assuming that the data set is
sorted.
|
int |
compareTo(DBIDRef o)
Compare two DBIDs for ordering.
|
boolean |
contains(DBIDRef o)
Test whether an ID is contained.
|
boolean |
equals(Object obj)
Deprecated.
|
DBID |
get(int i)
Get the i'th entry (starting at 0)
If possible, use an
DBIDArrayIter via ArrayDBIDs.iter() instead! |
int |
hashCode()
In contrast to
DBIDRef , the DBID interface is supposed to have a
stable hash code. |
int |
internalGetIndex()
Return the integer value of the object ID.
|
boolean |
isEmpty()
Test for an empty DBID collection.
|
DBIDArrayIter |
iter()
Iterable
|
int |
size()
Size of the DBID "collection".
|
String |
toString() |
protected final int id
public static final ByteBufferSerializer<DBID> DYNAMIC_SERIALIZER
public static final FixedSizeByteBufferSerializer<DBID> STATIC_SERIALIZER
protected IntegerDBID(int id)
id
- integer id.protected IntegerDBID(Integer id)
id
- integer id.public int internalGetIndex()
internalGetIndex
in interface DBIDRef
internalGetIndex
in interface IntegerDBIDRef
public int hashCode()
DBID
DBIDRef
, the DBID interface is supposed to have a
stable hash code. However, it is generally preferred to use optimized
storage classes instead of Java collections!@Deprecated public boolean equals(Object obj)
DBID
DBIDRef
, the DBID interface is supposed to have a
stable equals for other DBIDs.
Yet, DBIDUtil.equal(de.lmu.ifi.dbs.elki.database.ids.DBIDRef, de.lmu.ifi.dbs.elki.database.ids.DBIDRef)
is more type safe and explicit.public int compareTo(DBIDRef o)
DBID
DBIDUtil.compare(de.lmu.ifi.dbs.elki.database.ids.DBIDRef, de.lmu.ifi.dbs.elki.database.ids.DBIDRef)
, which is more explicit.compareTo
in interface DBID
compareTo
in interface Comparable<DBIDRef>
o
- Other DBID objectpublic DBIDArrayIter iter()
ArrayDBIDs
iter
in interface ArrayDBIDs
iter
in interface DBIDs
public DBID get(int i)
ArrayDBIDs
DBIDArrayIter
via ArrayDBIDs.iter()
instead!get
in interface ArrayDBIDs
i
- Indexpublic void assign(int index, DBIDVar var)
ArrayDBIDs
index
.assign
in interface ArrayDBIDs
index
- Positionvar
- Variable to assign the value to.public boolean contains(DBIDRef o)
DBIDs
public int size()
ArrayDBIDs
size
in interface ArrayDBIDs
size
in interface DBIDs
public int binarySearch(DBIDRef key)
ArrayDBIDs
-(1+insertion position)
is returned, as
for Java Collections.binarySearch(java.util.List<? extends java.lang.Comparable<? super T>>, T)
binarySearch
in interface ArrayDBIDs
key
- Key to search for