From 4ffe1bbac38a66a66fd2293fd2fe08b546497b02 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sat, 6 Jan 2018 17:14:00 -0600 Subject: [PATCH] make complexity of `Array.lookup` explicit (closes #174) --- src/core/CCArray.mli | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/CCArray.mli b/src/core/CCArray.mli index d0b5e4f9..c0a99efe 100644 --- a/src/core/CCArray.mli +++ b/src/core/CCArray.mli @@ -121,6 +121,8 @@ val find_idx : ('a -> bool) -> 'a t -> (int * 'a) option val lookup : ?cmp:'a ord -> 'a -> 'a t -> int option (** Lookup the index of some value in a sorted array. + Undefined behavior if the array is not sorted wrt [cmp]. + Complexity: [O(log (n))] (dichotomic search). @return [None] if the key is not present, or [Some i] ([i] the index of the key) otherwise *) @@ -134,7 +136,7 @@ val bsearch : ?cmp:('a -> 'a -> int) -> 'a -> 'a t -> provided [arr] is {b sorted} using [cmp]. If the array is not sorted, the result is not specified (may raise Invalid_argument). - Complexity: O(log n) where n is the length of the array + Complexity: [O(log n)] where n is the length of the array (dichotomic search). @return