Package elki.database.ids.integer
Class IntegerDBID
- java.lang.Object
-
- elki.database.ids.integer.IntegerDBID
-
- All Implemented Interfaces:
ArrayDBIDs,DBID,DBIDRef,DBIDs,IntegerDBIDRef,SetDBIDs,java.lang.Comparable<DBIDRef>
final class IntegerDBID extends java.lang.Object implements DBID, IntegerDBIDRef
Database ID object. While this currently is just an Integer, it should be avoided to store the object IDs in regular integers to reduce problems if this API ever changes (for example if someone needs to supportlong, 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.- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIntegerDBID.DynamicSerializerDynamic sized serializer, using varint.protected classIntegerDBID.ItrPseudo iterator for DBIDs interface.static classIntegerDBID.StaticSerializerStatic sized serializer, using regular integers.
-
Field Summary
Fields Modifier and Type Field Description static ByteBufferSerializer<DBID>DYNAMIC_SERIALIZERThe public instance to use for dynamic serialization.protected intidThe actual object ID.static FixedSizeByteBufferSerializer<DBID>STATIC_SERIALIZERThe public instance to use for static serialization.
-
Constructor Summary
Constructors Modifier Constructor Description protectedIntegerDBID(int id)Constructor from integer id.protectedIntegerDBID(java.lang.Integer id)Constructor from integer id.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DBIDVarassignVar(int index, DBIDVar var)Assign a DBID variable the value of positionindex.intbinarySearch(DBIDRef key)Search for the position of the given key, assuming that the data set is sorted.intcompareTo(DBIDRef o)Compare two DBIDs for ordering.booleancontains(DBIDRef o)Test whether an ID is contained.booleanequals(java.lang.Object obj)Deprecated.DBIDget(int i)Get the i'th entry (starting at 0)inthashCode()In contrast toDBIDRef, the DBID interface is supposed to have a stable hash code.intinternalGetIndex()Return the integer value of the object ID.booleanisEmpty()Test for an empty DBID collection.IntegerDBID.Itriter()Iterableintsize()Size of the DBID "collection".ArrayDBIDsslice(int begin, int end)Slice a subarray (as view, not copy!)java.lang.StringtoString()
-
-
-
Field Detail
-
id
protected final int id
The actual object ID.
-
DYNAMIC_SERIALIZER
public static final ByteBufferSerializer<DBID> DYNAMIC_SERIALIZER
The public instance to use for dynamic serialization.
-
STATIC_SERIALIZER
public static final FixedSizeByteBufferSerializer<DBID> STATIC_SERIALIZER
The public instance to use for static serialization.
-
-
Method Detail
-
internalGetIndex
public int internalGetIndex()
Return the integer value of the object ID.- Specified by:
internalGetIndexin interfaceDBIDRef- Specified by:
internalGetIndexin interfaceIntegerDBIDRef- Returns:
- integer id
-
size
public int size()
Description copied from interface:ArrayDBIDsSize of the DBID "collection".- Specified by:
sizein interfaceArrayDBIDs- Specified by:
sizein interfaceDBIDs- Returns:
- size
-
isEmpty
public boolean isEmpty()
Description copied from interface:DBIDsTest for an empty DBID collection.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
Description copied from interface:DBIDIn contrast toDBIDRef, 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!
-
equals
@Deprecated public boolean equals(java.lang.Object obj)
Deprecated.Description copied from interface:DBIDIn contrast toDBIDRef, the DBID interface is supposed to have a stable equals for other DBIDs.Yet,
DBIDUtil.equal(elki.database.ids.DBIDRef, elki.database.ids.DBIDRef)is more type safe and explicit.
-
compareTo
public int compareTo(DBIDRef o)
Description copied from interface:DBIDCompare two DBIDs for ordering.Consider using
DBIDUtil.compare(elki.database.ids.DBIDRef, elki.database.ids.DBIDRef), which is more explicit.
-
iter
public IntegerDBID.Itr iter()
Description copied from interface:ArrayDBIDsIterable- Specified by:
iterin interfaceArrayDBIDs- Specified by:
iterin interfaceDBIDs- Returns:
- Iterator
-
get
public DBID get(int i)
Description copied from interface:ArrayDBIDsGet the i'th entry (starting at 0)If possible, use an
DBIDArrayIterviaArrayDBIDs.iter()instead, or anDBIDVarviaArrayDBIDs.assignVar(int, elki.database.ids.DBIDVar)- Specified by:
getin interfaceArrayDBIDs- Parameters:
i- Index- Returns:
- DBID of i'th entry.
-
assignVar
public DBIDVar assignVar(int index, DBIDVar var)
Description copied from interface:ArrayDBIDsAssign a DBID variable the value of positionindex.- Specified by:
assignVarin interfaceArrayDBIDs- Parameters:
index- Positionvar- Variable to assign the value to.
-
contains
public boolean contains(DBIDRef o)
Description copied from interface:DBIDsTest whether an ID is contained.
-
binarySearch
public int binarySearch(DBIDRef key)
Description copied from interface:ArrayDBIDsSearch 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:
binarySearchin interfaceArrayDBIDs- Parameters:
key- Key to search for- Returns:
- Offset of key
-
slice
public ArrayDBIDs slice(int begin, int end)
Description copied from interface:ArrayDBIDsSlice a subarray (as view, not copy!)- Specified by:
slicein interfaceArrayDBIDs- Parameters:
begin- Begin (inclusive)end- End (exclusive)- Returns:
- Array slice.
-
-