/* ***************************************************************************
 $Workfile: MergeSorter.java$
   $Author: kalcock$
     $Date: 02/06/07 18:06:18$
 $Revision: 3$
 *****************************************************************************
 Package
 ****************************************************************************/
package com.keithalcock.t180;
/* ***************************************************************************
 Imports
 ****************************************************************************/

/* ***************************************************************************
 Class
 ****************************************************************************/
public class MergeSorter {

    protected static int copyArrayFromTo(int[] fromArray,int fromStart,int fromStop,
            int[] toArray,int toIndex) {
        for (int fromIndex=fromStart;fromIndex<fromStop;fromIndex++)
            toArray[toIndex++]=fromArray[fromIndex];
        return toIndex;
    }   
    
    protected static int[] merge(int[] leftArray,int[] rightArray) {



















        return new int[0];
    }

    public static int[] sort(int[] unsortedArray) {



















        return unsortedArray;
    }

    protected static boolean isSorted(int[] array) {
        for (int i=0;i<array.length-1;i++)
            if (!(array[i]<=array[i+1]))
                return false;
        return true;
    }

    protected static int testIndex=0;

    protected static void testMergeSorter(int[] testArray) {
        testIndex++;
        System.out.println("Test "+testIndex+" passed? "+
                isSorted(MergeSorterCode.sort(testArray)));
    }

    public static void main(String[] args) {
        testMergeSorter(new int[]{});
        testMergeSorter(new int[]{10});
        testMergeSorter(new int[]{10,-10});
        testMergeSorter(new int[]{1,2,3,4,5});
        testMergeSorter(new int[]{-1,2,-3,4,-5});
        testMergeSorter(new int[]{5,4,3,2,1});
    }
}
/* **************************************************************************/
