add CCMap.{keys,values}

This commit is contained in:
Simon Cruanes 2015-11-30 12:33:59 +01:00
parent 99919ae1d3
commit 191953feaf
2 changed files with 22 additions and 0 deletions

View file

@ -53,6 +53,14 @@ module type S = sig
val add_list : 'a t -> (key * 'a) list -> 'a t
(** @since 0.14 *)
val keys : _ t -> key sequence
(** Iterate on keys only
@since NEXT_RELEASE *)
val values : 'a t -> 'a sequence
(** Iterate on values only
@since NEXT_RELEASE *)
val to_list : 'a t -> (key * 'a) list
val pp : ?start:string -> ?stop:string -> ?arrow:string -> ?sep:string ->
@ -88,6 +96,12 @@ module Make(O : Map.OrderedType) = struct
let to_seq m yield =
iter (fun k v -> yield (k,v)) m
let keys m yield =
iter (fun k _ -> yield k) m
let values m yield =
iter (fun _ v -> yield v) m
let add_list m l = List.fold_left (fun m (k,v) -> add k v m) m l
let of_list l = add_list empty l

View file

@ -56,6 +56,14 @@ module type S = sig
val add_list : 'a t -> (key * 'a) list -> 'a t
(** @since 0.14 *)
val keys : _ t -> key sequence
(** Iterate on keys only
@since NEXT_RELEASE *)
val values : 'a t -> 'a sequence
(** Iterate on values only
@since NEXT_RELEASE *)
val to_list : 'a t -> (key * 'a) list
val pp : ?start:string -> ?stop:string -> ?arrow:string -> ?sep:string ->