/*
 * This class will be used to work with arrays of salaries
 * @author Jeff Borland(change)
 * @date 3-22-11
 */
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
public class ArrayActivities
{
   int[] allSalaries = new int [200000];
   Scanner scan;  
   private static long start;
   private static long finish;   
   
    /*
     * The constructor below will automatically read in all of the Baseball player salaries
     */
    public ArrayActivities() 
    {
        startClock();
        reset(); //resets the scanner to the beginning of the file
        int i=0;
        while (scan.hasNext() && i<200000)
        {
            String theLine=scan.nextLine(); //This reads in the next player line                           
            int salary=Integer.parseInt(theLine);  //converts the string salary to an integer
            allSalaries[i]=salary;
            i++;                       
        }
        stopClock();
        
    }
    
    public void sort()
    {
    	Arrays.sort(allSalaries); 
    }
    
    
    public static void startClock()
    {     
        start = System.currentTimeMillis();   
    }
    public static void stopClock()
    {
        finish= System.currentTimeMillis();   
        System.out.println( "This operation took " + (finish-start) + " milliseconds.");
    }

    
    
    
    //This method will reset your scanner to beginning of file
    //note it is private - why?
    private void reset()
    {
        //To reset your scanner:
        try
        {
            scan=new Scanner(new File("salaries.txt"));
        }
        catch (IOException e){}
    }
    
    public boolean findSalary(int salaryToCheck) 
    {    	
    	return true;
    }    
    
    public boolean findSalary(int[] salariesToCheck) 
    {
    	return true;
    }
    
    public boolean findFast(int salary)
    {
   		return false;
    }
    
    public boolean findFast(int[] salariesToCheck) 
    {
    	return true;
    }
    
    public static void main(String[] args) {
		ArrayActivities a = new ArrayActivities();
				
		/*startClock();
		System.out.println("1537158 is found:"+a.findSalary(1537158));
		stopClock();*/
		
		/*startClock();
		int[] sal={2342333,3089780,3987232,3423223,2345333,
				4788385,3423432,1369298,1914420};
		System.out.println("one of the sal is found:"+a.findSalary(sal));
		stopClock();*/
		
		//NOW SORT THE ARRAY TO TRY FAST FOUND
		startClock();
		a.sort();
		stopClock();
		
		/*startClock();
		System.out.println("1537158 is found:"+a.findSalary(1537158));
		stopClock();*/
		
		/*startClock();
		int[] sal={2342333,3089780,3987232,3423223,2345333,
				4788385,3423432,1369298,1914420};
		System.out.println("one of the sal is found:"+a.findSalary(sal));
		stopClock();*/
		
		startClock();
		System.out.println("1537158 is fast found:"+a.findFast(1537158));
		stopClock();
		
		/*startClock();
		int[] sal={2342333,3089780,3987232,3423223,2345333,
				4788385,3423432,1369298,1914420};
		System.out.println("one of the sal is fast found:"+a.findFast(sal));
		stopClock();*/
	}
    
}