Module Prime_accretion_map.Make1

Accretion map of a polymorphic monoid type.

Parameters

Signature

type key = Key.t
type 'a elt = 'a Elt.t
type 'a result = 'a Elt.t
type 'a t
val empty : 'a t

The empty map.

val singleton : key -> 'a elt -> 'a t

singleton k e is the map containing just e bound to k.

val is_empty : 'a t -> bool

is_empty m is true iff m is the empty map.

val cardinal : 'a t -> int

cardinal m is the number of bindings in m.

val result : 'a t -> 'a result

result m is the nested application of the monoid operator over elements of the map in key-order but arbitrary associative combination.

val app : 'a t -> key -> 'a elt option

app m is the partial function corresponding to the bindings of m.

val find : key -> 'a t -> 'a elt

find k m is the element mapped to k.

raises Not_found

if k has no binding in m

val add : key -> 'a elt -> 'a t -> 'a t

add k e m is the least map binding k to e and any k' ≠ k to find k' m.

val remove : key -> 'a t -> 'a t

remove k m is the minimal map binding k' ≠ k to find k' m.

val bindings : 'a t -> (key * 'a elt) list

bindings m is the list containing (k, e) iff k is bound to e in m.

val fold : (key -> 'a elt -> 'b -> 'b) -> 'a t -> 'b -> 'b

fold f m is f kₙ eₙ ∘ ... ∘ f k₁ e₁ where (kᵢ, eᵢ) are the bindings of m in key order.

val iter : (key -> 'a elt -> unit) -> 'a t -> unit

iter f m calls f k e for each binding (k, e) of m in key order.

search f m is f k e where (k, e) is the binding with smallest k for which f k e ≠ None, or None if m has no such binding.

val for_all : (key -> 'a elt -> bool) -> 'a t -> bool

for_all f m is true iff f k e is true for all bindings (k, e) of m.

val exists : (key -> 'a elt -> bool) -> 'a t -> bool

exists f m is true iff there is a bindng (k, e) of m such that f k e.