Class OrdinalCalculator


  • public class OrdinalCalculator
    extends Object
    Calculates ordinals of a comparable list by placing them in the correct positions in the list.

    Implements the QuickSelect algorithm, but modifies it to select multiple ordinals all at once.

    • Constructor Detail

      • OrdinalCalculator

        public OrdinalCalculator()
    • Method Detail

      • putOrdinalsInPosition

        public static <T extends Comparable<T>> void putOrdinalsInPosition​(List<T> list,
                                                                           Collection<Integer> ordinals)
        Calculates a set of ordinal values for a given list of comparable objects. Once the method returns, the each ordinal is guaranteed to have the correct value in the list.
        Parameters:
        list - the list of Comparable objects
        ordinals - the collection ordinals to calculate (0 to (size of list) - 1)