Module type Multiset.S
val size : t -> intNumber of distinct elements.
val cardinal : t -> Z.tNumber of unique occurrences of elements (the multiplicity of each element is considered)
val empty : tEmpty multiset
val is_empty : t -> boolIs the multiset empty?
val find : t -> elt -> Z.tReturn the multiplicity of the element within the multiset. Will return
Z.zeroif the element is not part of the multiset
val singleton : elt -> tval doubleton : elt -> elt -> tval add : t -> elt -> tAdd one occurrence of the element
val difference : t -> t -> tDifference of multisets. If
xhas a bigger multiplicity in the second argument it won't appear in the result
module Seq : sig ... endval for_all : (elt -> bool) -> t -> boolval exists : (elt -> bool) -> t -> boolval choose : t -> eltChose one element, or
- raises Not_found
if the multiset is empty
val of_coeffs : (elt * Z.t) list -> tFrom list of elements with multiplicities. Multiplicities lower than 0 will not count.
val of_array : elt array -> tval to_list : t -> (elt * Z.t) listList of elements with their coefficients
val cancel : t -> t -> t * tRemove common elements from the multisets. For instance, on
{1,1,2}and{1,2,2,3},cancelwill return({1}, {2,3})
Comparisons
In the following, the comparison function must be equality-compatible with E.compare. In other words, if E.compare x y = 0 then f x y = Comparison.Eq must hold.
val compare_partial : (elt -> elt -> Comparison.t) -> t -> t -> Comparison.tCompare two multisets with the multiset extension of the given ordering. This ordering is total iff the element ordering is.
val is_max : (elt -> elt -> Comparison.t) -> elt -> t -> boolIs the given element maximal (ie not dominated by any other element) within the multiset?
val max : (elt -> elt -> Comparison.t) -> t -> tMaximal elements of the multiset, w.r.t the given ordering.
val max_seq : (elt -> elt -> Comparison.t) -> t -> (elt * Z.t) Sequence.tFold on maximal elements
val max_l : (elt -> elt -> Comparison.t) -> elt list -> elt listMaximal elements of a list
val compare_partial_l : (elt -> elt -> Comparison.t) -> elt list -> elt list -> Comparison.tCompare two multisets represented as list of elements