org.apache.lucene.util

## Class Sorter

- java.lang.Object
- - org.apache.lucene.util.Sorter

- Direct Known Subclasses:
    InPlaceMergeSorter, IntroSorter, MSBRadixSorter, TimSorter

      public abstract class Sorter
      extends Object

  Base class for sorting algorithms implementations.
  NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `Sorter()` Sole constructor, used for inheritance.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract int` | `compare(int i, int j)` Compare entries found in slots `i` and `j`.
    `protected int` | `comparePivot(int j)` Compare the pivot with the slot at `j`, similarly to `compare(i, j)`.
    `protected void` | `setPivot(int i)` Save the value at slot `i` so that it can later be used as a pivot, see `comparePivot(int)`.
    `abstract void` | `sort(int from, int to)` Sort the slice which starts at `from` (inclusive) and ends at `to` (exclusive).
    `protected abstract void` | `swap(int i, int j)` Swap values at slots `i` and `j`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Sorter

          protected Sorter()

      Sole constructor, used for inheritance.

  - ### Method Detail

    - #### compare

          protected abstract int compare(int i,
                                         int j)

      Compare entries found in slots `i` and `j`. The contract for the returned value is the same as `Comparator.compare(Object, Object)`.

    - #### swap

          protected abstract void swap(int i,
                                       int j)

      Swap values at slots `i` and `j`.

    - #### setPivot

          protected void setPivot(int i)

      Save the value at slot `i` so that it can later be used as a pivot, see `comparePivot(int)`.

    - #### comparePivot

          protected int comparePivot(int j)

      Compare the pivot with the slot at `j`, similarly to `compare(i, j)`.

    - #### sort

          public abstract void sort(int from,
                                    int to)

      Sort the slice which starts at `from` (inclusive) and ends at `to` (exclusive).

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.