mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
Merge pull request #1 from nbraud/multiset
multiSet: Add contains function
This commit is contained in:
commit
f93c5865a4
2 changed files with 9 additions and 0 deletions
|
|
@ -51,6 +51,8 @@ module type S = sig
|
||||||
|
|
||||||
val diff : t -> t -> t
|
val diff : t -> t -> t
|
||||||
|
|
||||||
|
val contains : t -> t -> bool
|
||||||
|
|
||||||
val compare : t -> t -> int
|
val compare : t -> t -> int
|
||||||
|
|
||||||
val equal : t -> t -> bool
|
val equal : t -> t -> bool
|
||||||
|
|
@ -131,6 +133,11 @@ module Make(O : Set.OrderedType) = struct
|
||||||
else None)
|
else None)
|
||||||
m1 m2
|
m1 m2
|
||||||
|
|
||||||
|
let contains m1 m2 =
|
||||||
|
try
|
||||||
|
M.for_all (fun x c -> M.find x m1 >= c) m2
|
||||||
|
with Not_found -> false
|
||||||
|
|
||||||
let compare m1 m2 =
|
let compare m1 m2 =
|
||||||
M.compare (fun x y -> x - y) m1 m2
|
M.compare (fun x y -> x - y) m1 m2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,8 @@ module type S = sig
|
||||||
|
|
||||||
val diff : t -> t -> t
|
val diff : t -> t -> t
|
||||||
|
|
||||||
|
val contains : t -> t -> bool
|
||||||
|
|
||||||
val compare : t -> t -> int
|
val compare : t -> t -> int
|
||||||
|
|
||||||
val equal : t -> t -> bool
|
val equal : t -> t -> bool
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue