Enum TokenSorter

  • All Implemented Interfaces:
    Serializable, Comparable<TokenSorter>

    public enum TokenSorter
    extends Enum<TokenSorter>
    An object capable of producing a sort order permutation of a TokenSequence. The sequence is not modified by the sorter.

    These objects are thread-safe; the same TokenSorter can be used simultaneously by multiple threads.

    See Also:
    TokenOrder
    • Enum Constant Detail

      • HEAP_SORT

        public static final TokenSorter HEAP_SORT
        A sorter using the heap sort algorithm. Heap sort is in-place, reducing memory usage, but is not a stable sort.
      • MERGE_SORT

        public static final TokenSorter MERGE_SORT
        A sorter using the merge sort algorithm. Merge sort requires additional memory, but is a stable sort.
    • Method Detail

      • values

        public static TokenSorter[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (TokenSorter c : TokenSorter.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static TokenSorter valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • sort

        public int[] sort​(TokenSequence data)
        Builds a sort order permutation for the specified sequence, assuming a default of ascending order.
        Parameters:
        data - the sequence to sort
        Returns:
        an array of sequence indexes which puts the sequence in sorted order.
      • sort

        public int[] sort​(TokenSequence data,
                          TokenOrder sortOrder)
        Builds a sort order permutation for the specified sequence in the specified order. If the sequence is a composite, the order will be used for all columns of the composite.
        Parameters:
        data - the sequence to sort
        sortOrder - the ordering to use
        Returns:
        an array of sequence indexes which puts the sequence in sorted order.
      • sort

        public int[] sort​(RecordTokenSequence data,
                          TokenOrder[] sortOrder)
        Builds a sort order permutation for the specified composite sequence using the specified order for each column.
        Parameters:
        data - the composite sequence to sort
        sortOrder - the ordering to use. This must provide as many orderings as there are columns in the sequence.
        Returns:
        an array of sequence indexes which puts the sequence in sorted order.
      • sort

        public int[] sort​(RecordTokenSequence data,
                          SortKey... sortKeys)
        Builds a sort order permutation for the specified composite sequence using the given sort keys.
        Parameters:
        data - the composite sequence to sort
        sortKeys - definition of the sort keys to use
        Returns:
        an array of sequence indexes which puts the sequence in sorted order.
      • sort

        public int[] sort​(int rowCount,
                          ElementComparator comparator)
        Performs a sort based on an element comparator.
        Parameters:
        rowCount - The number of rows to be sorted
        comparator - A comparator that determines the ordering
        Returns:
        an array of sequence indexes which puts the elements in sorted order.