mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 19:55:31 -05:00
comments in CCMultiSet.mli, to explain meet/intersection/union
This commit is contained in:
parent
6d0e2fdd2d
commit
432f0f0abd
2 changed files with 14 additions and 4 deletions
|
|
@ -148,16 +148,16 @@ module Make(O : Set.OrderedType) = struct
|
|||
| Some n1, None -> Some n1
|
||||
| None, Some n2 -> None
|
||||
| Some n1, Some n2 ->
|
||||
if n1 > n2
|
||||
if n1 > n2
|
||||
then Some (n1 - n2)
|
||||
else None)
|
||||
m1 m2
|
||||
|
||||
let contains m1 m2 =
|
||||
try
|
||||
try
|
||||
M.for_all (fun x c -> M.find x m1 >= c) m2
|
||||
with Not_found -> false
|
||||
|
||||
|
||||
let compare m1 m2 =
|
||||
M.compare (fun x y -> x - y) m1 m2
|
||||
|
||||
|
|
|
|||
|
|
@ -46,25 +46,35 @@ module type S = sig
|
|||
val remove : t -> elt -> t
|
||||
|
||||
val min : t -> elt
|
||||
(** Minimal element w.r.t the total ordering on elements *)
|
||||
|
||||
val max : t -> elt
|
||||
|
||||
val union : t -> t -> t
|
||||
(** [union a b] contains as many occurrences of an element [x]
|
||||
as [count a x + count b x]. *)
|
||||
|
||||
val meet : t -> t -> t
|
||||
(** [meet a b] is a multiset such that
|
||||
[count (meet a b) x = max (count a x) (count b x)] *)
|
||||
|
||||
val intersection : t -> t -> t
|
||||
(** [intersection a b] is a multiset such that
|
||||
[count (intersection a b) x = min (count a x) (count b x)] *)
|
||||
|
||||
val diff : t -> t -> t
|
||||
(** MultiSet difference.
|
||||
[count (diff a b) x = max (count a x - count b x) 0] *)
|
||||
|
||||
val contains : t -> t -> bool
|
||||
(** [contains a x = (count m x > 0)] *)
|
||||
|
||||
val compare : t -> t -> int
|
||||
|
||||
val equal : t -> t -> bool
|
||||
|
||||
val cardinal : t -> int
|
||||
(** Number of distinct elements *)
|
||||
(** Number of distinct elements *)
|
||||
|
||||
val iter : t -> (int -> elt -> unit) -> unit
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue