aboutsummaryrefslogtreecommitdiff
path: root/lib/gmap.ml
diff options
context:
space:
mode:
authorherbelin2006-01-24 23:20:39 +0000
committerherbelin2006-01-24 23:20:39 +0000
commit3de3dbdc1eb3c0d299e6ef977aeb30a323c9de95 (patch)
tree9c2154acb2caacebad9a49600bc855b93e860a2b /lib/gmap.ml
parenta654f2eec4c2d446f69b06a07ed416f6412f49dd (diff)
Suppression de la dépendance en Map.fold de ocaml dont la sémantique a
changé entre les version 3.08.4 et 3.09.0 (influe notamment sur l'ordre d'application des Hints de auto) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@7925 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'lib/gmap.ml')
-rw-r--r--lib/gmap.ml22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/gmap.ml b/lib/gmap.ml
index 4febb3ad1d..858cb40c8b 100644
--- a/lib/gmap.ml
+++ b/lib/gmap.ml
@@ -8,7 +8,7 @@
(* $Id$ *)
(* Maps using the generic comparison function of ocaml. Code borrowed from
- the ocaml standard library. *)
+ the ocaml standard library (Copyright 1996, INRIA). *)
type ('a,'b) t =
Empty
@@ -81,12 +81,23 @@
let c = Pervasives.compare x v in
c = 0 || mem x (if c < 0 then l else r)
- let rec merge t1 t2 =
+ let rec min_binding = function
+ Empty -> raise Not_found
+ | Node(Empty, x, d, r, _) -> (x, d)
+ | Node(l, x, d, r, _) -> min_binding l
+
+ let rec remove_min_binding = function
+ Empty -> invalid_arg "Map.remove_min_elt"
+ | Node(Empty, x, d, r, _) -> r
+ | Node(l, x, d, r, _) -> bal (remove_min_binding l) x d r
+
+ let merge t1 t2 =
match (t1, t2) with
(Empty, t) -> t
| (t, Empty) -> t
- | (Node(l1, v1, d1, r1, h1), Node(l2, v2, d2, r2, h2)) ->
- bal l1 v1 d1 (bal (merge r1 l2) v2 d2 r2)
+ | (_, _) ->
+ let (x, d) = min_binding t2 in
+ bal t1 x d (remove_min_binding t2)
let rec remove x = function
Empty ->
@@ -109,6 +120,9 @@
Empty -> Empty
| Node(l, v, d, r, h) -> Node(map f l, v, f d, map f r, h)
+ (* Maintien de fold_right par compatibilité (changé en fold_left dans
+ ocaml-3.09.0) *)
+
let rec fold f m accu =
match m with
Empty -> accu