package logtk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Multiset.MakeSource

Parameters

Signature

Sourcetype elt = X.t

Elements of the multiset

Sourcetype t

A multiset of elements of type 'a

Sourceval size : t -> int

Number of distinct elements.

Sourceval cardinal : t -> Z.t

Number of unique occurrences of elements (the multiplicity of each element is considered)

Sourceval empty : t

Empty multiset

Sourceval is_empty : t -> bool

Is the multiset empty?

Sourceval mem : t -> elt -> bool

Is the element part of the multiset?

Sourceval find : t -> elt -> Z.t

Return the multiplicity of the element within the multiset. Will return Z.zero if the element is not part of the multiset

Sourceval singleton : elt -> t
Sourceval doubleton : elt -> elt -> t
Sourceval add : t -> elt -> t

Add one occurrence of the element

Sourceval add_coeff : t -> elt -> Z.t -> t

Add several occurrences of the element

Sourceval union : t -> t -> t

Union of multisets (max of multiplicies)

Sourceval intersection : t -> t -> t

Intersection of multisets (min of multiplicies)

Sourceval sum : t -> t -> t

Sum of multiplicies

Sourceval difference : t -> t -> t

Difference of multisets. If x has a bigger multiplicity in the second argument it won't appear in the result

Sourceval product : Z.t -> t -> t

Multiply all multiplicities with the given coefficient

Sourceval filter : (elt -> Z.t -> bool) -> t -> t

Filter out elements that don't satisfy the predicate

Sourceval map : (elt -> elt) -> t -> t

Apply a function to all elements

Sourceval map_coeff : (elt -> Z.t -> Z.t) -> t -> t

Apply a function to all coefficients.

Sourceval filter_map : (elt -> Z.t -> (elt * Z.t) option) -> t -> t

More powerful mapping

Sourceval flat_map : (elt -> t) -> t -> t

replace each element by a multiset in its own

Sourcemodule Seq : sig ... end
Sourceval iter : (elt -> unit) -> t -> unit

Iterate on distinct occurrences of elements

Sourceval fold : ('a -> elt -> 'a) -> 'a -> t -> 'a

fold on occurrences of elements

Sourceval iter_coeffs : (elt -> Z.t -> unit) -> t -> unit

Iterate on elements with their multiplicity

Sourceval fold_coeffs : ('a -> elt -> Z.t -> 'a) -> 'a -> t -> 'a

Fold on elements with their multiplicity

Sourceval for_all : (elt -> bool) -> t -> bool
Sourceval exists : (elt -> bool) -> t -> bool
Sourceval choose : t -> elt

Chose one element, or

Sourceval of_list : elt list -> t

Multiset from list

Sourceval of_coeffs : (elt * Z.t) list -> t

From list of elements with multiplicities. Multiplicities lower than 0 will not count.

Sourceval of_iarray : elt IArray.t -> t

From immutable array

Sourceval of_array : elt array -> t
Sourceval to_list : t -> (elt * Z.t) list

List of elements with their coefficients

Sourceval equal : t -> t -> bool

Check equality of two multisets

Sourceval cancel : t -> t -> t * t

Remove common elements from the multisets. For instance, on {1,1,2} and {1,2,2,3}, cancel will 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.

Sourceval compare : t -> t -> int

Compare two multisets with the multiset extension of E.compare

Sourceval compare_partial : (elt -> elt -> Comparison.t) -> t -> t -> Comparison.t

Compare two multisets with the multiset extension of the given ordering. This ordering is total iff the element ordering is.

Sourceval is_max : (elt -> elt -> Comparison.t) -> elt -> t -> bool

Is the given element maximal (ie not dominated by any other element) within the multiset?

Sourceval max : (elt -> elt -> Comparison.t) -> t -> t

Maximal elements of the multiset, w.r.t the given ordering.

Sourceval max_seq : (elt -> elt -> Comparison.t) -> t -> (elt * Z.t) Iter.t

Fold on maximal elements

Sourceval max_l : (elt -> elt -> Comparison.t) -> elt list -> elt list

Maximal elements of a list

Sourceval compare_partial_l : (elt -> elt -> Comparison.t) -> elt list -> elt list -> Comparison.t

Compare two multisets represented as list of elements

OCaml

Innovation. Community. Security.