Class 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 support 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.
    Since:
    0.4.0
    Author:
    Erich Schubert
    • 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.
    • Constructor Detail

      • IntegerDBID

        protected IntegerDBID​(int id)
        Constructor from integer id.
        Parameters:
        id - integer id.
      • IntegerDBID

        protected IntegerDBID​(java.lang.Integer id)
        Constructor from integer id.
        Parameters:
        id - integer id.
    • Method Detail

      • size

        public int size()
        Description copied from interface: ArrayDBIDs
        Size of the DBID "collection".
        Specified by:
        size in interface ArrayDBIDs
        Specified by:
        size in interface DBIDs
        Returns:
        size
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: DBIDs
        Test for an empty DBID collection.
        Specified by:
        isEmpty in interface DBIDs
        Returns:
        true when empty.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Description copied from interface: DBID
        In contrast to 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!
        Specified by:
        hashCode in interface DBID
        Specified by:
        hashCode in interface DBIDRef
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hash code
      • equals

        @Deprecated
        public boolean equals​(java.lang.Object obj)
        Deprecated.
        Description copied from interface: DBID
        In contrast to DBIDRef, 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.

        Specified by:
        equals in interface DBID
        Specified by:
        equals in interface DBIDRef
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - Other object
        Returns:
        true when the object is the same DBID.
      • assignVar

        public DBIDVar assignVar​(int index,
                                 DBIDVar var)
        Description copied from interface: ArrayDBIDs
        Assign a DBID variable the value of position index.
        Specified by:
        assignVar in interface ArrayDBIDs
        Parameters:
        index - Position
        var - Variable to assign the value to.
      • contains

        public boolean contains​(DBIDRef o)
        Description copied from interface: DBIDs
        Test whether an ID is contained.
        Specified by:
        contains in interface DBIDs
        Parameters:
        o - object to test
        Returns:
        true when contained
      • 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 Java Collections.binarySearch(java.util.List<? extends java.lang.Comparable<? super T>>, T)

        Specified by:
        binarySearch in interface ArrayDBIDs
        Parameters:
        key - Key to search for
        Returns:
        Offset of key
      • slice

        public ArrayDBIDs slice​(int begin,
                                int end)
        Description copied from interface: ArrayDBIDs
        Slice a subarray (as view, not copy!)
        Specified by:
        slice in interface ArrayDBIDs
        Parameters:
        begin - Begin (inclusive)
        end - End (exclusive)
        Returns:
        Array slice.