wi@TN55.5.0+dev0-2025-04-28/#Map+OrderedTypeB!tA;@@@A@@@@@4../../stdlib/map.mliss@@@@#Map@@A@'compare@#Map+OrderedType!t@@@@#Map+OrderedType!t@@@#int@@@@@@@@)v*v @@(A@@@@-q.~  @,B@@!SE#keyC;@@>A@@@@@=F > B>F > J@@@@@@?@OSOv@@Q@@/max_binding_opt$@#Map!S!t!a@KE@B@@@D)@#Map!S#key@@@E@@@F@@@H@@I@56(@@4R@@&choose%@#Map!S!t!a@SE@L@@@N@#Map!S#key@@@O@@@P@@Q@ab@@`S@@*choose_opt&@#Map!S!t!a@]E@T@@@V@#Map!S#key@@@W@@@X@@@Z@@[@@@T@@$find'@#Map!S#key@@@^@#Map!S!t!a@eE@_@@@a@@b@@c@@@U@@(find_opt(@#Map!S#key@@@f@#Map!S!t!a@oE@g@@@i @@@k@@l@@m@dhd@@V@@*find_first)@@#Map!S#key@@@p$bool@@@q@@r@#Map!S!t!a@{E@s@@@u@#Map!S#key@@@v@@@w@@x@@y@' * .( * _@@&W@@.find_first_opt*@@#Map!S#key@@@|@@@@}@@~@#Map!S!t!a@E@@@@_@#Map!S#key@@@@@@@@@@@@@@k"E"Il"E"@@jX@@)find_last+@@#Map!S#key@@@@@@@@@#Map!S!t!a@E@@@@@#Map!S#key@@@@@@@@@@@#z#~#z#@@Y@@-find_last_opt,@@#Map!S#key@@@@@@@@@#Map!S!t!a@E@@@@@#Map!S#key@@@@@@@@@@@@@@$$$$@@Z@@$iter-@@#Map!S#key@@@@!a@E@$unit@@@@@@@@#Map!S!t@@@@@@@@@@@%%%&%&'@@$[@@$fold.@@#Map!S#key@@@@!a@E@@#acc@E@@@@@@@@#Map!S!t@@@@@@@@@@@['@'D\'N'@@Z\@@#map/@@!a@E@!b@E@@@@#Map!S!t@@@#Map!S!t@@@@@@@@((((@@]@@$mapi0@@#Map!S#key@@@@!a@E@!b@E@@@@@@#Map!S!t@@@#Map!S!t@@@@@@@@)))*@@^@@&filter1@@#Map!S#key@@@@!a@E@@@@@@@@@#Map!S!t@@@#Map!S!t"@@@@@@@@****@@_@@*filter_map2@@#Map!S#key@@@@!a@E@-!b@E@@@@@@@@@#Map!S!t@@@#Map!S!t@@@@@@@@G ,,"H ,,Z@@F`@@)partition3@@#Map!S#key@@@@!a@E@h@@@@@@@@#Map!S!t@@@@#Map!S!t&@@@@#Map !S!t3@@@@@@@@@@////@@@a@@%split4@#Map !S#key@@@ @#Map !S!t!a@E@ @@@ @#Map !S!t@@@@֠@@@@#Map !S!t)@@@@@@@@@@$0B0F$0B0w@@b@@(is_empty5@#Map!S!t!a@E@@@@@@@@@@0282<0282V@@c@@#mem6@#Map!S#key@@@@#Map!S!t!a@'E@ @@@"*@@@#@@$@@%@-322.322@@,d@@%equal7@@!a@5E@(@D@@@)@@*@@+@#Map!S!t@@@-@#Map!S!t&@@@/c@@@0@@1@@2@@3@f733g733H@@ee@@'compare8@@!a@CE@6@X@@@7@@8@@9@#Map!S!t@@@;@#Map!S!t&@@@=w@@@>@@?@@@@@A@=4C4G=4C4|@@f@@'for_all9@@#Map!S#key@@@D@!a@OE@E@@@F@@G@@H@#Map!S!t@@@J@@@K@@L@@M@A55A55K@@g@@&exists:@@#Map!S#key@@@P@!a@[E@Q @@@R@@S@@T@#Map!!S!t@@@V"@@@W@@X@@Y@ F55 F55@@ h@@'to_list;@#Map#!S!t!a@eE@\@@@^b%@#Map$!S#key@@@_@@@`@@@b@@c@=M66>M66@@@@ @@ @'@$@#@ @@@ @ @@@ @(@@ @@@ @@ @ @ @ @!@@@ @@@@ @ @@ @@ @@@@4@@@ @4@@@ @@@ @@@ @@ @@@@K@@@ @H@@@ @@@ @@ @@@@^@@@ @^@@@ @@@ @@@ @@ @@@@j@@@ @z@@@ @@ @@ @@@@y@@@ @{@@@ u@@@ @@ @@ @t@q@p@@@@@ hE@@@ @@ @`@@@ @@@@ @j@@ @@ @@ @S@P@O@@@@@ @@@ @@ @?@@@ 9@@@@ @L@@ @@@ @@ @@ @1@.@-@@@@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a total ordering function over the keys. All operations over maps are purely applicative (no side-effects). The implementation uses balanced binary trees, and therefore searching and insertion take time logarithmic in the size of the map.@5 For instance: U module IntPairs = struct type t = int * int let compare (x0,y0) (x1,y1) = match Stdlib.compare x0 x1 with 0 -> Stdlib.compare y0 y1 | c -> c end module PairsMap = Map.Make(IntPairs) let m = PairsMap.(empty |> add (0,1) "hello" |> add (1,0) "world") @> This creates a new module (PairsMap2, with a new type -'a PairsMap.t1 of maps from )int * int$ to "'a3. In this example, !m* contains &string: values so its type is 1string PairsMap.t!.@@@@@@@@@@@@A4../../stdlib/map.mli/Map.OrderedType3?Input signature of the functor (Map.Make@@!.@@@@@@@@@@@@kA#1Map.OrderedType.t39The type of the map keys.@@@@@@@@@@@@@@A@@rp@@7Map.OrderedType.compare3 SA total ordering function over the keys. This is a two-argument function !f5 such that 'f e1 e25 is zero if the keys "e1% and "e26 are equal, 'f e1 e29 is strictly negative if "e11 is smaller than "e20, and 'f e1 e29 is strictly positive if "e11 is greater than "e2 j. Example: a suitable ordering function is the generic structural comparison function .Stdlib.compare@@!.@@@@@@@@@@@@@ @@@@@@@@%Map.S3 Output signature of the functor y@@!.@@@@@@@@@@@@AA$maps$Maps@@#)Map.S.key39The type of the map keys.@@@@@@@@@@@@@@A@@@@#'Map.S.t3;The type of maps from type #key) to type "'a!.@@@@@@@@@@@@I@@A@@@@+Map.S.empty3.The empty map.@@@@@@@@@@@@@@@@)Map.S.add3.add key data m 7 returns a map containing the same bindings as !m4, plus a binding of #key$ to $data%. If #key> was already bound in !m ( to a value that is physically equal to $data*, !m W is returned unchanged (the result of the function is then physically equal to !m .). Otherwise, the previous binding of #key$ in !m, disappears.@@@@@$4.03 "Physical equality was not ensured.@@@@@@@@@@@@@@@٠1Map.S.add_to_list36add_to_list key data m$ is !m& with #key+ mapped to !l3 such that !l$ is 6data :: Map.find key m$ if #key6 was bound in !m% and &[data]+ otherwise.@@@@#5.1@@@@@@@@@@@@@@᠕,Map.S.update3.update key f m 7 returns a map containing the same bindings as !m<, except for the binding of #key $. Depending on the value of !y' where !y$ is 2f (find_opt key m)1, the binding of #key * is added, removed or updated. If !y$ is $None =, the binding is removed if it exists; otherwise, if !y$ is &Some z& then #key: is associated to !z; in the resulting map. If #key> was already bound in !m ( to a value that is physically equal to !z", !m _ is returned unchanged (the result of the function is then physically equal to !m").@@@@$4.06@@@@@@@M@uN@xE@{2@@@@/Map.S.singleton3-singleton x y = returns the one-element map that contains a binding !y% for !x!.@@@@$3.12@@@@@@@0@1@(@@@@,Map.S.remove3*remove x m 7 returns a map containing the same bindings as !m-, except for !x 2 which is unbound in the returned map. If !x, was not in !m", !m W is returned unchanged (the result of the function is then physically equal to !m").@@@@@$4.03 "Physical equality was not ensured.@@@@@@@@G@H@?@@@@%+Map.S.merge3-merge f m1 m2 ? computes a map whose keys are a subset of the keys of "m1( and of "m2 j. The presence of each such binding, and the corresponding value, is determined with the function !f:. In terms of the (find_opt< operation, we have @find_opt x (merge f m1 m2) = f x (find_opt x m1) (find_opt x m2)5 for any key !x0, provided that 4f x None None = None!.@@@@$3.12@@@@@@@U@V@&@!@@@@+Map.S.union3-union f m1 m2 ? computes a map whose keys are a subset of the keys of "m1( and of "m2 L. When the same binding is defined in both arguments, the function !f < is used to combine them. This is a special case of %merge": -union f m1 m2: is equivalent to .merge f' m1 m2', where8f' _key None None = None@>f' _key (Some v) None = Some v@>f' _key None (Some v) = Some v@ (f' key (Some v1) (Some v2) = f key v1 v2@@@@@@$4.03@@@@@@@D@kE@n+@q!@@@@ .Map.S.cardinal3 'Return the number of bindings of a map.@@@@$3.12@@@@@@@@@@@@A(bindings(Bindings@@.Map.S.bindings3 Return the list of all bindings of the given map. The returned list is sorted in increasing order of keys with respect to the ordering +Ord.compare(, where #Ord " is the argument given to  @@!.@@@@$3.12@@@@@@@@@@@@1Map.S.min_binding3 UReturn the binding with the smallest key in a given map (with respect to the +Ord.compare= ordering), or raise )Not_found5 if the map is empty.@@@@$3.12@@@@@@@@@@@@蠕5Map.S.min_binding_opt3 WReturn the binding with the smallest key in the given map (with respect to the +Ord.compare/ ordering), or $None= if the map is empty.@@@@$4.05@@@@@@@@@@@@Ԡ1Map.S.max_binding3(Same as CD@ H, but returns the binding with the largest key in the given map.@@@@$3.12@@@@@@@@@@@@5Map.S.max_binding_opt3(Same as =D@ H, but returns the binding with the largest key in the given map.@@@@$4.05@@@@@@@@@@@@,Map.S.choose3 .Return one binding of the given map, or raise )Not_found  if the map is empty. Which binding is chosen is unspecified, but equal bindings will be chosen for equal maps.@@@@$3.12@@@@@@@@-@@@@0Map.S.choose_opt3 (Return one binding of the given map, or $None  if the map is empty. Which binding is chosen is unspecified, but equal bindings will be chosen for equal maps.@@@@$4.05@@@@@@@@D@@@@vA)searching)Searching@@*Map.S.find3(find x m> returns the current value of !x$ in !m4, or raises )Not_found3 if no binding for !x( exists.@@@@@@@@@@@@@w@z@@@@.Map.S.find_opt3,find_opt x m) returns &Some v9 if the current value of !x, in !m$ is !v%, or $None3 if no binding for !x( exists.@@@@$4.05@@@@@@@@@@@@@0Map.S.find_first3.find_first f m(, where !f H is a monotonically increasing function, returns the binding of !m5 with the lowest key !k+ such that #f k4, or raises )Not_found7 if no such key exists.@6 For example, ,find_first (fun k -> Ord.compare k x >= 0) m ' will return the first binding $k, v$ of !m' where 4Ord.compare k x >= 07 (intuitively: &k >= x,), or raise )Not_found$ if !x ( is greater than any element of !m!.@@@@$4.05@@@@@@@@@@@@@4Map.S.find_first_opt32find_first_opt f m(, where !f ] is a monotonically increasing function, returns an option containing the binding of !m= with the lowest key !k+ such that #f k%, or $None7 if no such key exists.@@@@$4.05@@@@@@@@P@S@@@@/Map.S.find_last3-find_last f m(, where !f H is a monotonically decreasing function, returns the binding of !m6 with the highest key !k+ such that #f k4, or raises )Not_found7 if no such key exists.@@@@$4.05@@@@@@@@@@@@@3Map.S.find_last_opt31find_last_opt f m(, where !f ] is a monotonically decreasing function, returns an option containing the binding of !m> with the highest key !k+ such that #f k%, or $None? if no such key exists.@@@@$4.05@@@@@@@@@@@@@A*traversing*Traversing@@*Map.S.iter3(iter f m) applies !f8 to all bindings in map !m*. !f v receives the key as first argument, and the associated value as second argument. The bindings are passed to !f T in increasing order with respect to the ordering over the type of the keys.@@@@@@@@@@@@@@@@@@*Map.S.fold3-fold f m init* computes ?(f kN dN ... (f k1 d1 init)...)0, where )k1 ... kN ! are the keys of all bindings in !m $ (in increasing order), and )d1 ... dN9 are the associated data.@@@@@@@@@@@@@@ @#@@@@A,transforming,Transforming@@)Map.S.map3'map f m # returns a map with same domain as !m %, where the associated value !a4 of all bindings of !m ? has been replaced by the result of the application of !f$ to !a %. The bindings are passed to !f T in increasing order with respect to the ordering over the type of the keys.@@@@@@@@@@@@@b@e@@@@*Map.S.mapi3(Same as BD@ s, but the function receives as arguments both the key and the associated value for each binding of the map.@@@@@@@@@@@@@z@}@@@@x,Map.S.filter3*filter f m * returns the map with all the bindings in !m that satisfy predicate !p6. If every binding in !m+ satisfies !f*, !m W is returned unchanged (the result of the function is then physically equal to !m!)@@@@$3.12$4.03 "Physical equality was not ensured.@@@@@@@@@@@@@@}0Map.S.filter_map3.filter_map f m6 applies the function !f= to every binding of !m >, and builds a map from the results. For each binding &(k, v)2 in the input map:#if %f k v$ is $None& then !k6 is not in the result,@#if %f k v$ is 'Some v'2 then the binding '(k, v') is in the output map.@@ T For example, the following function on maps whose values are lists m filter_map (fun _k li -> match li with [] -> None | _::tl -> Some tl) m ? drops all bindings of !m b whose value is an empty list, and pops the first element of each value that is non-empty.@@@@$4.11@@@@@@@@!@$@@@@/Map.S.partition3-partition f m8 returns a pair of maps ((m1, m2)0, where "m1> contains all the bindings of !m $ that satisfy the predicate !f&, and "m2 - is the map with all the bindings of !m5 that do not satisfy !f!.@@@@$3.12@@@@@@@@b@e@@@@+Map.S.split3)split x m2 returns a triple ,(l, data, r)2, where !l % is the map with all the bindings of !m ) whose key is strictly less than !x,; !r % is the map with all the bindings of !m , whose key is strictly greater than !x,; $data$ is $None$ if !m9 contains no binding for !x/, or &Some v$ if !m' binds !v$ to !x!.@@@@$3.12@@@@@@@@@@@@@A*predicates:Predicates and comparisons@@.Map.S.is_empty3 #Test whether a map is empty or not.@@@@@@@@@@@@@@@@@)Map.S.mem3'mem x m) returns $true$ if !m8 contains a binding for !x., and %false+ otherwise.@@@@@@@@@@@@@@@@@@+Map.S.equal3/equal cmp m1 m28 tests whether the maps "m1% and "m2 ] are equal, that is, contain equal keys and associate them with equal data. #cmp U is the equality predicate used to compare the data associated with the keys.@@@@@@@@@@@@@?@B@E@@@@-Map.S.compare3 Total ordering between maps. The first argument is a total ordering used to compare data associated with equal keys in the two maps.@@@@@@@@@@@@@T@W@Z@@@@-Map.S.for_all3+for_all f m E checks if all the bindings of the map satisfy the predicate !f!.@@@@$3.12@@@@@@@@t@wt@@@@f,Map.S.exists3*exists f m K checks if at least one binding of the map satisfies the predicate !f!.@@@@$3.12@@@@@@@r@s@[@@@@MA*converting*Converting@@-Map.S.to_list3)to_list m$ is D@" m!.@@@@#5.1@@@@@@@e@f@@@@A-Map.S.of_list3*of_list bs6 adds the bindings of "bs E to the empty map, in list order (if a key is bound twice in "bs " the last one takes over).@@@@#5.1@@@@@@@S@T@@@@/,Map.S.to_seq3 4Iterate on the whole map, in ascending order of keys@@@@$4.07@@@@@@@2@3@@@@ 0Map.S.to_rev_seq3 5Iterate on the whole map, in descending order of keys@@@@$4.12@@@@@@@ @ @@@@ 㠕1Map.S.to_seq_from3/to_seq_from k m ) iterates on a subset of the bindings of !m /, in ascending order of keys, from key !k* or above.@@@@$4.07@@@@@@@ @ @ @@@@ à-Map.S.add_seq3 ,Add the given bindings to the map, in order.@@@@$4.07@@@@@@@ @0 @3 @@@@ ,Map.S.of_seq3 #Build a map from the given bindings@@@@$4.07@@@@@@@ @D @@@@ m@@ k j@/ f3 XFunctor building an implementation of the map structure given a totally ordered type.@@@@@@@@@@@@AĢ j#Map:+OrderedType+OrderedType@UW6 with type key = Ord.t@  j@@@@@@@@@A 0@@@@@