Class SimpleSearcher

java.lang.Object
  extended by SimpleSearcher

public class SimpleSearcher
extends java.lang.Object

The SimpleSearcher Java application runs a small test on the search method that searches for a specified number in an array.

Java Source Code for this class:
http://www.cs.colorado.edu/~main/applications/SimpleSearcher.java


Constructor Summary
SimpleSearcher()
           
 
Method Summary
static void main(java.lang.String[] args)
          The main method prints a table of test results, searching for numbers in an array that contains 2, 4, 6, 8, 10, 12, and 14.
static boolean search(double[] data, double target)
          Search an array for a specified number.
static boolean search2(double[] data, double target)
          Search an array for a specified number.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSearcher

public SimpleSearcher()
Method Detail

main

public static void main(java.lang.String[] args)
The main method prints a table of test results, searching for numbers in an array that contains 2, 4, 6, 8, 10, 12, and 14. The String arguments (args) are not used in this implementation.


search

public static boolean search(double[] data,
                             double target)
Search an array for a specified number.

Parameters:
data - an array of double numbers
target - a particular number that we are searching for
Returns:
true (to indicate that target occurs somewhere in the array) or false (to indicate that target is not in the array)

search2

public static boolean search2(double[] data,
                              double target)
Search an array for a specified number. This implementation uses the new form of a for-loop to iterate through the elements of an array.

Parameters:
data - an array of double numbers
target - a particular number that we are searching for
Returns:
true (to indicate that target occurs somewhere in the array) or false (to indicate that target is not in the array)