val binary_search : ?pos:int -> ?len:int -> 't -> length:('t -> int) -> get:('t -> int -> 'elt) -> compare:('elt -> 'key -> int) -> [ `Last_strictly_less_than | `Last_less_than_or_equal_to | `Last_equal_to | `First_equal_to | `First_greater_than_or_equal_to | `First_strictly_greater_than ] -> 'key -> int optionbinary_search ?pos ?len t ~length ~get ~compare which elttakestthat is sorted in increasing order according tocompare, wherecompareandeltdividetinto three (possibly empty) segments:| < elt | = elt | > elt |
binary_searchreturns the index intof an element on the boundary of segments as specified bywhich. See the diagram below next to thewhichvariants.By default,
binary_searchsearches the entiret. One can supply?posor?lento search a slice oft.binary_searchdoes not check thatcompareorderst, and behavior is unspecified ifcomparedoesn't ordert. Behavior is also unspecified ifcomparemutatest.
val binary_search_segmented : ?pos:int -> ?len:int -> 't -> length:('t -> int) -> get:('t -> int -> 'elt) -> segment_of:('elt -> [ `Left | `Right ]) -> [ `Last_on_left | `First_on_right ] -> int optionbinary_search_segmented ?pos ?len t ~length ~get ~segment_of whichtakes asegment_offunction that dividestinto two (possibly empty) segments:| segment_of elt = `Left | segment_of elt = `Right |
binary_search_segmentedreturns the index of the element on the boundary of the segments as specified bywhich:`Last_on_leftyields the index of the last element of the left segment, while`First_on_rightyields the index of the first element of the right segment. It returnsNoneif the segment is empty.By default,
binary_searchsearches the entiret. One can supply?posor?lento search a slice oft.binary_search_segmenteddoes not check thatsegment_ofsegmentstas in the diagram, and behavior is unspecified ifsegment_ofdoesn't segmentt. Behavior is also unspecified ifsegment_ofmutatest.