package TCSLib

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

Output signature of the functor FSet.Make.

type key

The domain type.

type 'a t

The range type.

val size : 'a t -> int

Returns the size of the domain of a map.

Map comparison

val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

equal cmp m1 m2 tests whether the maps m1 and m2 are equal. Two maps are equal if they have equal domains and map each domain element to equal values, where the values are compared using cmp.

val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool

compare cmp returns a total ordering on maps using cmp to compare values.

Map construction

val empty : 'a t

The empty map.

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

add x y m returns a map that maps x to y and all other elements to the values they are mapped to by m.

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

remove x m returns a map that is undefined at x and maps all other elements to the values they are mapped to by m.

Iterators

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

iter f m applies f to all pairs x and y, where (x, y) is an element of m. The elements of m are processed in increasing domain order.

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

fold f m a returns (f xn yn ... (f x2 y2 (f x1 y1 a)) ... ), where (x1, y1), ..., (xn, yn) are the elements of m in increasing domain order.

val rev_fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b

fold f m a returns (f x1 y1 (f x2 y2 ... (f xn yn a)) ... ), where (x1, y1), ..., (xn, yn) are the elements of m in increasing domain order.

val map : ('a -> 'b) -> 'a t -> 'b t

map f m returns a map that has the same domain as m and maps all elements x in its domain to f (find x m).

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

mapi f m returns a map that has the same domain as m and maps all elements x in its domain to f x (find x m).

Scanning

val is_empty : 'a t -> bool

Tests whether a map has an empty domain.

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

for_all p m returns true if p x y = true for all elements (x, y) of m, and false otherwise.

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

for_all p m returns true if p x y = true some element (x, y) of m, and false otherwise.

Searching

val mem : key -> 'a t -> bool

mem x m tests whether m is defined at x.

val is_defined : key -> 'a t -> bool

is_defined x m tests whether m is defined at x (the same as mem).

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

find x m returns the value x is mapped to by m.

  • raises Not_found

    if x is not in the domain of m.

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

apply m x returns the value x is mapped to by m (the same as find).

  • raises Not_found

    if x is not in the domain of m.

Conversion

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

Returns an association list containing all element of the map in increasing order of the domain elements.

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

Creates a map from an association list.

OCaml

Innovation. Community. Security.