# Class Sorter.ASorter

public abstract class ASorter
extends Object

A Template Method design pattern abstract sorter. An abstract ordering strategy is required that must be matched to the type of objects being sorted.

##

aOrder

##

ASorter (AOrder)
  The constructor for this class

##

join (Object[], int, int, int)
  Joins sorted A[lo:s-1] and sorted A[s:hi] into A[lo:hi]
setOrder (AOrder)
  An accessor method for the abstract ordering strategy
sort (Object[], int, int)
  Sorts by doing a split-sort-sort-join
split (Object[], int, int)
  Splits A[lo:hi] into A[lo:s-1] and A[s:hi] where s is the returned value of this function

##

aOrder

    protected AOrder aOrder

##

ASorter

    protected  ASorter(AOrder aOrder)

  The constructor for this class.

  Parameters:
    aOrder - The abstracdt ordering strategy to be used by any subclass.

##

sort

    public final void sort(Object[] A, int lo, int hi)

  Sorts by doing a split-sort-sort-join. Splits the original array into two subarrays, recursively sorts the split subarrays, then re-joins the sorted subarrays together. This is the template method. It calls the abstract methods split and join to do the work. All comparison-based sorting algorithms are concrete subclasses with specific split and join methods.

  Parameters:
    A - the array A[lo:hi] to be sorted.
    lo - the low index of A.
    hi - the high index of A.

split

    protected abstract int split(Object[] A, int lo, int hi)

  Splits A[lo:hi] into A[lo:s-1] and A[s:hi] where s is the returned value of this function.

  Parameters:
    A - the array A[lo:hi] to be sorted.
    lo - the low index of A.
    hi - the high index of A.

join

    protected abstract void join(Object[] A, int lo, int s, int hi)

  Joins sorted A[lo:s-1] and sorted A[s:hi] into A[lo:hi].

  Parameters:
    A - A[lo:s-1] and A[s:hi] are sorted.
    lo - the low index of A.
    hi - the high index of A.

setOrder

    public void setOrder(AOrder aOrder)

  An accessor method for the abstract ordering strategy.

  Parameters:
    aOrder -