Commit 3f5d178f authored by Andrei Paskevich's avatar Andrei Paskevich

Extmap: add [domain] and [subdomain]

parent 559e03ee
......@@ -78,6 +78,8 @@ module type S =
val keys: 'a t -> key list
val values: 'a t -> 'a list
val of_list : (key * 'a) list -> 'a t
val domain : 'a t -> unit t
val subdomain : (key -> 'a -> bool) -> 'a t -> unit t
val is_num_elt : int -> 'a t -> bool
type 'a enumeration
val val_enum : 'a enumeration -> (key * 'a) option
......@@ -623,4 +625,8 @@ module type S =
let of_list l =
List.fold_left (fun acc (k,d) -> add k d acc) empty l
let domain m = map ignore m
let subdomain pr m = mapi_filter (fun k v ->
if pr k v then Some () else None) m
end
......@@ -271,6 +271,13 @@ module type S =
val of_list: (key * 'a) list -> 'a t
(** construct a map from a pair of bindings *)
val domain : 'a t -> unit t
(** [domain m] returns the set of keys of binding [m] *)
val subdomain : (key -> 'a -> bool) -> 'a t -> unit t
(** [subdomain pr m] returns the set of keys of bindings in [m]
that satisfy predicate [pr] *)
val is_num_elt : int -> 'a t -> bool
(** check if the map has the given number of elements *)
......
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