# Class Sorter.ShakerSorter

public class ShakerSorter
extends Sorter.ASorter

##

forwardState
reverseState
state

##

ShakerSorter (AOrder)

##

join (Object[], int, int, int)
  Joins sorted A[lo:s-1] and sorted A[s:hi] into A[lo:hi]
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

##

forwardState

    private ShakerSorter.AState forwardState = new AState()
     	{
    		public int split(Object[] A, int lo, int hi)
      		{
    			int j = hi;
    			while (lo < j)
    			{
    				if (aOrder.lt(A[j],A[j-1]))
    				{
    	            	Object temp = A[j];
    	            	A[j] = A[j-1];
    	            	A[j-1] = temp;
    	         	}
    	         	j--;
    	      	}
            	state = reverseState;
    			return lo + 1;
    	    }
    	}

reverseState

    private ShakerSorter.AState reverseState = new AState()
     	{
    		public int split(Object[] A, int lo, int hi)
      		{
    			int j = lo;
    			while (j < hi)
    			{
    				if (aOrder.lt(A[j+1],A[j]))
    				{
    	            	Object temp = A[j];
    	            	A[j] = A[j+1];
    	            	A[j+1] = temp;
    	         	}
    	         	j++;
    	      	}
            	state = forwardState;
    			return hi;
        	}
      	}

state

    private ShakerSorter.AState state = forwardState

##

ShakerSorter

    public  ShakerSorter(AOrder iCompareOp)

  Parameters:
    iCompareOp -

##

split

    protected 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.
  Returns:

join

    protected 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.
    s -
    hi - the high index of A.