package com.jeffbrower.sort;

import java.util.Comparator;

abstract class SortMethod {
    private final String name;
    
    SortMethod(String name) {
        this.name = name;
    }
    
    @Override
    public String toString() {
        return name;
    }
    
    final long time(byte[] a) {
        long start = System.nanoTime();
        sort(a, 0, a.length);
        return System.nanoTime() - start;
    }
    
    final long time(char[] a) {
        long start = System.nanoTime();
        sort(a, 0, a.length);
        return System.nanoTime() - start;
    }
    
    final long time(short[] a) {
        long start = System.nanoTime();
        sort(a, 0, a.length);
        return System.nanoTime() - start;
    }
    
    final long time(int[] a) {
        long start = System.nanoTime();
        sort(a, 0, a.length);
        return System.nanoTime() - start;
    }
    
    final long time(long[] a) {
        long start = System.nanoTime();
        sort(a, 0, a.length);
        return System.nanoTime() - start;
    }
    
    final long time(float[] a) {
        long start = System.nanoTime();
        sort(a, 0, a.length);
        return System.nanoTime() - start;
    }
    
    final long time(double[] a) {
        long start = System.nanoTime();
        sort(a, 0, a.length);
        return System.nanoTime() - start;
    }
    
    final <T extends Comparable<T>> long time(T[] a) {
        long start = System.nanoTime();
        sort(a, 0, a.length);
        return System.nanoTime() - start;
    }
    
    final <T> long time(T[] a, Comparator<T> c) {
        long start = System.nanoTime();
        sort(a, 0, a.length, c);
        return System.nanoTime() - start;
    }
    
    final void sort(byte[] a) {
        sort(a, 0, a.length);
    }
    
    final void sort(char[] a) {
        sort(a, 0, a.length);
    }
    
    final void sort(short[] a) {
        sort(a, 0, a.length);
    }
    
    final void sort(int[] a) {
        sort(a, 0, a.length);
    }
    
    final void sort(long[] a) {
        sort(a, 0, a.length);
    }
    
    final void sort(float[] a) {
        sort(a, 0, a.length);
    }
    
    final void sort(double[] a) {
        sort(a, 0, a.length);
    }
    
    final <T extends Comparable<T>> void sort(T[] a) {
        sort(a, 0, a.length);
    }
    
    final <T> void sort(T[] a, Comparator<T> c) {
        sort(a, 0, a.length, c);
    }
    
    abstract void sort(byte[] a, int low, int high);
    
    abstract void sort(char[] a, int low, int high);
    
    abstract void sort(short[] a, int low, int high);
    
    abstract void sort(int[] a, int low, int high);
    
    abstract void sort(long[] a, int low, int high);
    
    abstract void sort(float[] a, int low, int high);
    
    abstract void sort(double[] a, int low, int high);
    
    abstract <T extends Comparable<T>> void sort(T[] a, int low, int high);
    
    abstract <T> void sort(T[] a, int low, int high, Comparator<T> c);
}
