Commit 8e5d3b0b authored by POTTIER Francois's avatar POTTIER Francois

New function [StringMap.multiple_add].

parent 0c125b92
......@@ -28,3 +28,12 @@ let restrict domain map =
let domain map =
fold (fun key _ acu -> StringSet.add key acu) map StringSet.empty
let multiple_add k v m =
let vs =
find k m
with Not_found ->
add k (v :: vs) m
......@@ -13,6 +13,8 @@
include Map.S with type key = string
(* [cardinal m] is the cardinal of the map [m]. *)
val cardinal : 'a t -> int
(* [restrict s m] restricts the domain of the map [m] to (its
......@@ -26,4 +28,11 @@ val restrict: StringSet.t -> 'a t -> 'a t
val filter: (string -> 'a -> bool) -> 'a t -> 'a t
(* [domain m] returns the domain of the map [m]. *)
val domain: 'a t -> StringSet.t
(* [multiple_add k v m] adds the key-value pair [k, v] to the map [m],
which maps keys to *lists* of values. The list currently associated
with [k] is extended with the value [v]. *)
val multiple_add: key -> 'a -> 'a list t -> 'a list t
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment