Class ArrayModifiableIntegerDBIDs

    • Field Detail

      • store

        private int[] store
        The backing array list.
      • size

        private int size
        Occupied size.
    • Constructor Detail

      • ArrayModifiableIntegerDBIDs

        protected ArrayModifiableIntegerDBIDs​(int isize)
        Constructor.
        Parameters:
        isize - Initial size
      • ArrayModifiableIntegerDBIDs

        protected ArrayModifiableIntegerDBIDs()
        Constructor.
      • ArrayModifiableIntegerDBIDs

        protected ArrayModifiableIntegerDBIDs​(DBIDs existing)
        Constructor.
        Parameters:
        existing - Existing ids
    • Method Detail

      • size

        public int size()
        Description copied from interface: DBIDs
        Retrieve the collection / data size.
        Specified by:
        size in interface ArrayDBIDs
        Specified by:
        size in interface DBIDs
        Returns:
        collection size
      • 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.
      • ensureSize

        private void ensureSize​(int minsize)
        Resize as desired.
        Parameters:
        minsize - Desired size
      • grow

        private void grow()
        Grow array by 50%.
      • addDBIDs

        public boolean addDBIDs​(DBIDs ids)
        Description copied from interface: ModifiableDBIDs
        Add DBIDs to collection.
        Specified by:
        addDBIDs in interface ModifiableDBIDs
        Parameters:
        ids - IDs to add.
        Returns:
        true if the collection changed.
      • removeDBIDs

        public boolean removeDBIDs​(DBIDs ids)
        Description copied from interface: ModifiableDBIDs
        Remove DBIDs from collection.
        Specified by:
        removeDBIDs in interface ModifiableDBIDs
        Parameters:
        ids - IDs to remove.
        Returns:
        true if the collection changed.
      • add

        public boolean add​(DBIDRef e)
        Description copied from interface: ModifiableDBIDs
        Add a single DBID to the collection.
        Specified by:
        add in interface ModifiableDBIDs
        Parameters:
        e - ID to add
        Returns:
        true if the collection changed.
      • remove

        public boolean remove​(DBIDRef o)
        Description copied from interface: ModifiableDBIDs
        Remove a single DBID from the collection.
        Specified by:
        remove in interface ModifiableDBIDs
        Parameters:
        o - ID to remove
        Returns:
        true if the collection changed.
      • set

        public void set​(int index,
                        DBIDRef element)
        Description copied from interface: ArrayModifiableDBIDs
        Replace the i'th entry (starting at 0)
        Specified by:
        set in interface ArrayModifiableDBIDs
        Parameters:
        index - Index
        element - New value
      • insert

        public void insert​(int i,
                           DBIDRef newval)
        Description copied from interface: ArrayModifiableDBIDs
        Insert at position i (starting at 0, moving the remainder by one position).

        Note: this operation has linear time complexity on average: O(n/2)

        Specified by:
        insert in interface ArrayModifiableDBIDs
        Parameters:
        i - Index
        newval - New value
      • remove

        public void remove​(int index)
        Description copied from interface: ArrayModifiableDBIDs
        Remove the entry at position i by shifting the remainder forward.
        Specified by:
        remove in interface ArrayModifiableDBIDs
        Parameters:
        index - Index
      • removeSwap

        public void removeSwap​(int index)
        Description copied from interface: ArrayModifiableDBIDs
        Remove the entry at position i by swapping with the last (not preserving the order).
        Specified by:
        removeSwap in interface ArrayModifiableDBIDs
        Parameters:
        index - Entry offset to remove
      • 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
      • 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
      • sort

        public void sort​(int start,
                         int end,
                         java.util.Comparator<? super DBIDRef> comparator)
        Description copied from interface: ArrayModifiableDBIDs
        Sort the DBID set.
        Specified by:
        sort in interface ArrayModifiableDBIDs
        Parameters:
        start - Starting index, for partial sorting
        end - End index, for partial sorting (exclusive)
        comparator - Comparator to use
      • swap

        public void swap​(int a,
                         int b)
        Description copied from interface: ArrayModifiableDBIDs
        Swap DBIDs add positions a and b.
        Specified by:
        swap in interface ArrayModifiableDBIDs
        Parameters:
        a - First position
        b - Second position
      • pop

        public DBIDVar pop​(DBIDVar var)
        Description copied from interface: ModifiableDBIDs
        Pop (get and remove) one DBID from the set, into a variable.
        Specified by:
        pop in interface ModifiableDBIDs
        Parameters:
        var - Output variable
        Returns:
        Always outvar, for inlining
      • toString

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