package colibri2

  1. Overview
  2. Docs

The module of association tables over elt.

include Map_intf.Map with type 'a data := 'a Map_intf.punit with type 'a t = 'a M.t with type key = M.key
type key = M.key

The type of the map keys.

type 'a t = 'a M.t

The type of maps from type key to type 'a.

val hash_fold_t : 'a Map_intf.punit Base.Hash.folder -> 'a Map_intf.punit t Base.Hash.folder
val empty : 'a Map_intf.punit t

The empty map.

val is_empty : 'a Map_intf.punit t -> bool

Test whether a map is empty or not.

val mem : key -> 'a Map_intf.punit t -> bool

mem x m returns true if m contains a binding for x, and false otherwise.

val add : key -> 'a Map_intf.punit -> 'a Map_intf.punit t -> 'a Map_intf.punit t

add x y m returns a map containing the same bindings as m, plus a binding of x to y. If x was already bound in m, its previous binding disappears.

val singleton : key -> 'a Map_intf.punit -> 'a Map_intf.punit t

singleton x y returns the one-element map that contains a binding y for x.

val remove : key -> 'a Map_intf.punit t -> 'a Map_intf.punit t

remove x m returns a map containing the same bindings as m, except for x which is unbound in the returned map.

val merge : (key -> 'a Map_intf.punit option -> 'b Map_intf.punit option -> 'c Map_intf.punit option) -> 'a Map_intf.punit t -> 'b Map_intf.punit t -> 'c Map_intf.punit t

merge f m1 m2 computes a map whose keys is a subset of keys of m1 and of m2. The presence of each such binding, and the corresponding value, is determined with the function f.

val compare : ('a Map_intf.punit -> 'a Map_intf.punit -> int) -> 'a Map_intf.punit t -> 'a Map_intf.punit t -> int

Total ordering between maps. The first argument is a total ordering used to compare data associated with equal keys in the two maps.

val equal : ('a Map_intf.punit -> 'a Map_intf.punit -> bool) -> 'a Map_intf.punit t -> 'a Map_intf.punit t -> bool

equal cmp m1 m2 tests whether the maps m1 and m2 are equal, that is, contain equal keys and associate them with equal data. cmp is the equality predicate used to compare the data associated with the keys.

val iter : (key -> 'a Map_intf.punit -> unit) -> 'a Map_intf.punit t -> unit

iter f m applies f to all bindings in map m. f receives the key as first argument, and the associated value as second argument. The bindings are passed to f in increasing order with respect to the ordering over the type of the keys.

val fold : (key -> 'a Map_intf.punit -> 'b -> 'b) -> 'a Map_intf.punit t -> 'b -> 'b

fold f m a computes (f kN dN ... (f k1 d1 a)...), where k1 ... kN are the keys of all bindings in m (in increasing order), and d1 ... dN are the associated data.

val for_all : (key -> 'a Map_intf.punit -> bool) -> 'a Map_intf.punit t -> bool

for_all p m checks if all the bindings of the map satisfy the predicate p.

val exists : (key -> 'a Map_intf.punit -> bool) -> 'a Map_intf.punit t -> bool

exists p m checks if at least one binding of the map satisfy the predicate p.

val filter : (key -> 'a Map_intf.punit -> bool) -> 'a Map_intf.punit t -> 'a Map_intf.punit t

filter p m returns the map with all the bindings in m that satisfy predicate p.

val partition : (key -> 'a Map_intf.punit -> bool) -> 'a Map_intf.punit t -> 'a Map_intf.punit t * 'a Map_intf.punit t

partition p m returns a pair of maps (m1, m2), where m1 contains all the bindings of s that satisfy the predicate p, and m2 is the map with all the bindings of s that do not satisfy p.

val cardinal : 'a Map_intf.punit t -> int

Return the number of bindings of a map.

val bindings : 'a Map_intf.punit t -> (key * 'a Map_intf.punit) list

Return the list of all bindings of the given map. The returned list is sorted in increasing order with respect to the ordering Ord.compare, where Ord is the argument given to Extmap.Make.

val min_binding : 'a Map_intf.punit t -> key * 'a Map_intf.punit

Return the smallest binding of the given map (with respect to the Ord.compare ordering), or raise Not_found if the map is empty.

val max_binding : 'a Map_intf.punit t -> key * 'a Map_intf.punit

Same as Extmap.S.min_binding, but returns the largest binding of the given map.

val choose : 'a Map_intf.punit t -> key * 'a Map_intf.punit

Return one binding of the given map, or raise Not_found if the map is empty. Which binding is chosen is unspecified, but equal bindings will be chosen for equal maps.

val split : key -> 'a Map_intf.punit t -> 'a Map_intf.punit t * 'a Map_intf.punit option * 'a Map_intf.punit t

split x m returns a triple (l, data, r), where l is the map with all the bindings of m whose key is strictly less than x; r is the map with all the bindings of m whose key is strictly greater than x; data is None if m contains no binding for x, or Some v if m binds v to x.

val find : key -> 'a Map_intf.punit t -> 'a Map_intf.punit

find x m returns the current binding of x in m, or raises Not_found if no such binding exists.

map f m returns a map with same domain as m, where the associated value a of all bindings of m has been replaced by the result of the application of f to a. The bindings are passed to f in increasing order with respect to the ordering over the type of the keys.

val mapi : (key -> 'a Map_intf.punit -> 'b Map_intf.punit) -> 'a Map_intf.punit t -> 'b Map_intf.punit t

Same as Extmap.S.map, but the function receives as arguments both the key and the associated value for each binding of the map.

Added in Why3

val change : ('a Map_intf.punit option -> 'a Map_intf.punit option) -> key -> 'a Map_intf.punit t -> 'a Map_intf.punit t

change f x m returns a map containing the same bindings as m, except the binding of x in m is changed from y to f (Some y) if m contains a binding of x, otherwise the binding of x becomes f None.

change f x m corresponds to a more efficient way to do match (try f (Some (find x m)) with Not_found -> f None) with | None -> m | Some v -> add x v

val add_change : ('b -> 'a Map_intf.punit) -> ('b -> 'a Map_intf.punit -> 'a Map_intf.punit) -> key -> 'b -> 'a Map_intf.punit t -> 'a Map_intf.punit t

add_change empty add x b m corresponds to a more efficient and simpler way to do change (function | None -> Some (empty b) | Some l -> Some (add b l)) x m

val union : (key -> 'a Map_intf.punit -> 'a Map_intf.punit -> 'a Map_intf.punit option) -> 'a Map_intf.punit t -> 'a Map_intf.punit t -> 'a Map_intf.punit t

union f m1 m2 computes a map whose keys is a subset of keys of m1 and of m2. If a binding is present in m1 (resp. m2) and not in m2 (resp. m1) the same binding is present in the result. The function f is called only in ambiguous cases.

val union_merge : (key -> 'a Map_intf.punit option -> 'b Map_intf.punit -> 'a Map_intf.punit option) -> 'a Map_intf.punit t -> 'b Map_intf.punit t -> 'a Map_intf.punit t

Between union for the first argument and merge for the second argument

val inter : (key -> 'a Map_intf.punit -> 'b Map_intf.punit -> 'c Map_intf.punit option) -> 'a Map_intf.punit t -> 'b Map_intf.punit t -> 'c Map_intf.punit t

inter f m1 m2 computes a map whose keys is a subset of the intersection of keys of m1 and of m2.

val diff : (key -> 'a Map_intf.punit -> 'b Map_intf.punit -> 'a Map_intf.punit option) -> 'a Map_intf.punit t -> 'b Map_intf.punit t -> 'a Map_intf.punit t

diff f m1 m2 computes a map whose keys is a subset of keys of m1. f is applied on key which belongs to m1 and m2 if f returns None the binding is removed from m1, otherwise Some d1 is returned, the key binds to d1 in m1

val submap : (key -> 'a Map_intf.punit -> 'b Map_intf.punit -> bool) -> 'a Map_intf.punit t -> 'b Map_intf.punit t -> bool

submap pr m1 m2 verifies that all the keys in m1 are in m2 and that for each such binding pr is verified.

val disjoint : (key -> 'a Map_intf.punit -> 'b Map_intf.punit -> bool) -> 'a Map_intf.punit t -> 'b Map_intf.punit t -> bool

disjoint pr m1 m2 verifies that for every common key in m1 and m2, pr is verified.

val set_union : 'a Map_intf.punit t -> 'a Map_intf.punit t -> 'a Map_intf.punit t

set_union = union (fun _ x _ -> Some x)

val set_inter : 'a Map_intf.punit t -> 'b Map_intf.punit t -> 'a Map_intf.punit t

set_inter = inter (fun _ x _ -> Some x)

val set_diff : 'a Map_intf.punit t -> 'b Map_intf.punit t -> 'a Map_intf.punit t

set_diff = diff (fun _ _ _ -> None)

val set_submap : 'a Map_intf.punit t -> 'b Map_intf.punit t -> bool

set_submap = submap (fun _ _ _ -> true)

val set_disjoint : 'a Map_intf.punit t -> 'b Map_intf.punit t -> bool

set_disjoint = disjoint (fun _ _ _ -> false)

val set_compare : 'a Map_intf.punit t -> 'b Map_intf.punit t -> int

set_compare = compare (fun _ _ -> 0)

val set_equal : 'a Map_intf.punit t -> 'b Map_intf.punit t -> bool

set_equal = equal (fun _ _ -> true)

val find_def : 'a Map_intf.punit -> key -> 'a Map_intf.punit t -> 'a Map_intf.punit

find_def x d m returns the current binding of x in m, or return d if no such binding exists.

val find_opt : key -> 'a Map_intf.punit t -> 'a Map_intf.punit option

find_opt x m returns the Some of the current binding of x in m, or return None if no such binding exists.

val find_exn : exn -> key -> 'a Map_intf.punit t -> 'a Map_intf.punit

find_exn exn x d m returns the current binding of x in m, or raise exn if no such binding exists.

val find_remove : key -> 'a Map_intf.punit t -> 'a Map_intf.punit t * 'a Map_intf.punit option

find_remove x m returns the map without the binding and the binding

val add_opt : key -> 'a Map_intf.punit option -> 'a Map_intf.punit t -> 'a Map_intf.punit t

Just add or remove the binding if a data is or not given

val find_smaller_opt : key -> 'a Map_intf.punit t -> (key * 'a Map_intf.punit) option

return the binding of the maximum key smaller than the given key.

val map_filter : ('a Map_intf.punit -> 'b Map_intf.punit option) -> 'a Map_intf.punit t -> 'b Map_intf.punit t

Same as Extmap.S.map, but may remove bindings.

val mapi_filter : (key -> 'a Map_intf.punit -> 'b Map_intf.punit option) -> 'a Map_intf.punit t -> 'b Map_intf.punit t

Same as Extmap.S.mapi, but may remove bindings.

val mapi_fold : (key -> 'a Map_intf.punit -> 'acc -> 'acc * 'b Map_intf.punit) -> 'a Map_intf.punit t -> 'acc -> 'acc * 'b Map_intf.punit t

fold and map at the same time

val mapi_filter_fold : (key -> 'a Map_intf.punit -> 'acc -> 'acc * 'b Map_intf.punit option) -> 'a Map_intf.punit t -> 'acc -> 'acc * 'b Map_intf.punit t

Same as Extmap.S.mapi_fold, but may remove bindings.

val fold_left : ('b -> key -> 'a Map_intf.punit -> 'b) -> 'b -> 'a Map_intf.punit t -> 'b

same as fold but in the order of List.fold_left

val fold2_inter : (key -> 'a Map_intf.punit -> 'b Map_intf.punit -> 'c -> 'c) -> 'a Map_intf.punit t -> 'b Map_intf.punit t -> 'c -> 'c

fold the common keys of two map at the same time

val fold2_union : (key -> 'a Map_intf.punit option -> 'b Map_intf.punit option -> 'c -> 'c) -> 'a Map_intf.punit t -> 'b Map_intf.punit t -> 'c -> 'c

fold the keys which appear in one of the two maps

val fold_decr : ('b -> key -> 'a Map_intf.punit -> 'b) -> 'b -> 'a Map_intf.punit t -> 'b

same as fold_left but in decreasing order

val translate : (key -> key) -> 'a Map_intf.punit t -> 'a Map_intf.punit t

translate f m translates the keys in the map m by the function f. f must be strictly monotone on the key of m. Otherwise it raises invalid_arg

val add_new : exn -> key -> 'a Map_intf.punit -> 'a Map_intf.punit t -> 'a Map_intf.punit t

add_new e x v m binds x to v in m if x is not bound, and raises e otherwise.

val keys : 'a Map_intf.punit t -> key list

Return the list of all keys of the given map. The returned list is sorted in increasing order with respect to the ordering Ord.compare, where Ord is the argument given to Extmap.Make.

val values : 'a Map_intf.punit t -> 'a Map_intf.punit list

Return the list of all values of the given map. The returned list is sorted in increasing order with respect to the ordering Ord.compare of the keys, where Ord is the argument given to Extmap.Make.

val of_list : (key * 'a Map_intf.punit) list -> 'a Map_intf.punit t

construct a map from a pair of bindings

val is_num_elt : int -> 'a Map_intf.punit t -> bool

check if the map has the given number of elements

val choose_rnd : (unit -> bool) -> 'a Map_intf.punit t -> key * 'a Map_intf.punit

choose an element randomly (but non-uniformly), the given function is the random generator

type 'a enumeration

enumeration: zipper style

val val_enum : 'a Map_intf.punit enumeration -> (key * 'a Map_intf.punit) option

get the current key value pair of the enumeration, return None if the enumeration reach the end

val start_enum : 'a Map_intf.punit t -> 'a Map_intf.punit enumeration

start the enumeration of the given map

get the next step of the enumeration

val start_ge_enum : key -> 'a Map_intf.punit t -> 'a Map_intf.punit enumeration

start the enumeration of the given map at the first key which is greater or equal than the given one

get the next (or same) step of the enumeration which key is greater or equal to the given key

val check_invariant : 'a Map_intf.punit t -> bool

Check if the internal invariant are verified. Only for debugging the datastructure

OCaml

Innovation. Community. Security.