/** * Collections of objects amenable to search with binary search. * * @author Samuel A. Rebelsky * @version 1.0 of November 1999 */ public interface BinarySearchable { /** * Get the ``middle'' key in the collection. * Pre: The collection is nonempty. * Post: Returns some designated element in the collection. */ public Object middle(); /** * Get elements in the collection that are smaller than the * middle element. * Pre: The collection is nonempty. * Pre: The collection has not been modified since the last call * to middle. * Post: Returns the smaller elements. */ public BinarySearchable smaller(); /** * Get elements in the collection that are larger than the * middle element. * Pre: The collection is nonempty. * Pre: The collection has not been modified since the last call * to middle. * Post: Returns the larger elements. */ public BinarySearchable larger(); /** * Determine if the collection is empty. */ public boolean isEmpty(); } // BinarySearchable