--
-- Version: @(#)bsearch.ada 1.1  Date: 5/30/84
--
-- Authors:  Marion Moon and Bryce Bardin
--           Software Engineering Division
--           Ground Systems Group
--           Hughes Aircraft Company
--           Fullerton, CA
--
-- This package implements a generic binary search function.
-- It was designed to allow the use of an enumeration type for the table

-- index (a feature of possibly dubious utility, but included here for
-- uniformity with other generic operations on unconstrained arrays).
--
generic

    type Index is (<>);
    type Item is limited private;
    type Table is array (Index range <>) of Item;

    with function "=" (Left, Right : Item) return Boolean is <>;
    with function ">" (Left, Right : Item) return Boolean is <>;

package Searching is

    function Index_Of (Key : in Item; Within : in Table) return Index;
    -- Returns the Index of the Item in Within which matches Key
    -- if there is one, otherwise raises Not_Found.

    Not_Found : exception;
    -- Raised if the search fails.

end Searching;
