Class ArrayIntroSorter<T>


final class ArrayIntroSorter<T> extends IntroSorter
An IntroSorter for object arrays.
  • Field Details

    • arr

      private final T[] arr
    • comparator

      private final Comparator<? super T> comparator
    • pivot

      private T pivot
  • Constructor Details

  • Method Details

    • compare

      protected int compare(int i, int j)
      Description copied from class: Sorter
      Compare entries found in slots i and j. The contract for the returned value is the same as Comparator.compare(Object, Object).
      Overrides:
      compare in class IntroSorter
    • swap

      protected void swap(int i, int j)
      Description copied from class: Sorter
      Swap values at slots i and j.
      Specified by:
      swap in class Sorter
    • setPivot

      protected void setPivot(int i)
      Description copied from class: Sorter
      Save the value at slot i so that it can later be used as a pivot, see Sorter.comparePivot(int).
      Specified by:
      setPivot in class IntroSorter
    • comparePivot

      protected int comparePivot(int i)
      Description copied from class: Sorter
      Compare the pivot with the slot at j, similarly to compare(i, j).
      Specified by:
      comparePivot in class IntroSorter