mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
Move definition of CCMap.update so that it is shadowed by Stdlib.Map.update
Signed-off-by: Josh Berdine <josh@berdine.net>
This commit is contained in:
parent
d81cba4b06
commit
e6f77edf1a
1 changed files with 9 additions and 9 deletions
|
|
@ -166,6 +166,15 @@ module Make(O : Map.OrderedType) = struct
|
||||||
| None -> raise Not_found
|
| None -> raise Not_found
|
||||||
| Some (k,v) -> k, v
|
| Some (k,v) -> k, v
|
||||||
|
|
||||||
|
let update k f m =
|
||||||
|
let x =
|
||||||
|
try f (Some (M.find k m))
|
||||||
|
with Not_found -> f None
|
||||||
|
in
|
||||||
|
match x with
|
||||||
|
| None -> M.remove k m
|
||||||
|
| Some v' -> M.add k v' m
|
||||||
|
|
||||||
include M
|
include M
|
||||||
|
|
||||||
let get = find_opt
|
let get = find_opt
|
||||||
|
|
@ -174,15 +183,6 @@ module Make(O : Map.OrderedType) = struct
|
||||||
try find k m
|
try find k m
|
||||||
with Not_found -> default
|
with Not_found -> default
|
||||||
|
|
||||||
let update k f m =
|
|
||||||
let x =
|
|
||||||
try f (Some (find k m))
|
|
||||||
with Not_found -> f None
|
|
||||||
in
|
|
||||||
match x with
|
|
||||||
| None -> remove k m
|
|
||||||
| Some v' -> add k v' m
|
|
||||||
|
|
||||||
let merge_safe ~f a b =
|
let merge_safe ~f a b =
|
||||||
merge
|
merge
|
||||||
(fun k v1 v2 -> match v1, v2 with
|
(fun k v1 v2 -> match v1, v2 with
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue