import Comparator; /** * An object that knows how to search. * * @author Samuel A. Rebelsky * @version 1.0 of November 1999 */ public class BinarySearcher { /** * Search for an object u sing binary search. */ public boolean binarySearch(BinarySearchable stuff, Object findMe, Comparator compare) throws Exception { if (stuff.isEmpty()) return false; else if (compare.equals(findMe, stuff.middle())) return true; else if (compare.lessThan(findMe, stuff.middle())) return binarySearch(stuff.smaller(), findMe, compare); else return binarySearch(stuff.larger(), findMe, compare); } // binarySearch(BinarySearchable, Object, Comparator) } // BinarySearcher