Class RowComparator

    • Field Detail

      • m_Indices

        protected int[] m_Indices
        the column indices to use in the comparison.
      • m_Ascending

        protected boolean[] m_Ascending
        whether to sort ascending or descending.
    • Constructor Detail

      • RowComparator

        public RowComparator​(int[] indices)
        Initializes the comparator. Uses ascending sort order for all columns.
        Parameters:
        indices - the indices of the columns to compare
      • RowComparator

        public RowComparator​(int[] indices,
                             boolean[] ascending)
        Initializes the comparator.
        Parameters:
        indices - the indices of the columns to compare
        ascending - whether to sort ascending or descending, asending if null
    • Method Detail

      • getIndices

        public int[] getIndices()
        Returns the indices used for sorting.
        Returns:
        the (0-based) indices
      • getAscending

        public boolean[] getAscending()
        Returns whether a column is sorted in ascending or descending order.
        Returns:
        the sorting order
      • compare

        public int compare​(Row o1,
                           Row o2)
        Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
        Specified by:
        compare in interface Comparator<Row>
        Parameters:
        o1 - the first object to be compared.
        o2 - the second object to be compared.
        Returns:
        a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
      • toString

        public String toString()
        Returns a short description of the comparator.
        Overrides:
        toString in class Object
        Returns:
        the description