SML/NJ Library Manual

The BSearchFn functor


functor BSearchFn (MONO_ARRAY) : sig ... end

The BSearchFn functor implements binary searching on sorted monomorphic arrays.

Functor result interface

structure A : MONO_ARRAY
val bsearch : (('a * A.elem) -> order) -> ('a * A.array) -> (int * A.elem) option


bsearch cmp (a, arr)
performs a binary search, looking for a in the monomorphic array arr. It is assumed that the array elements have some key, and have been sorted non-decreasingly in terms of that key. The comparison function cmp is used to compare the elements of the array with the value a.

If the search is successful, the element and its index are returned; otherwise; NONE is returned.

See Also

ArrayQSortFn, ArrayQSort

[ Top | Parent | Contents | Index | Root ]

Last Modified June 9, 1998
Comments to John Reppy
Copyright © 1998 Bell Labs, Lucent Technologies