module type S =sig
..end
type +'a
t
typekey =
int
val empty : 'a t
val is_empty : 'a t -> bool
val add : ?merge:('a -> 'a -> 'a) -> int -> 'a -> 'a t -> 'a t
add ~merge:f k d m
returns a map containing the same bindings as
m
, plus a binding of k
to d
. If k
was already bound to
d'
in m
, then the value f d' d
is added instead of d
. If
no merge function is specified, then the previous bindings is
simply discard.
val modify : int -> ('a option -> 'a) -> 'a t -> 'a t
val find : int -> 'a t -> 'a
val findi_element : (int -> 'a -> bool) -> 'a t -> int * 'a
findi_element f t
returns the first couple (index,element) in map t
for which f ind elt
, with ind
an index and elt
the corresponding element, returns true.
Not_found
if t
is empty or if f
returns false for all
elements.val find_element : ('a -> bool) -> 'a t -> 'a
val remove : int -> 'a t -> 'a t
val mem : int -> 'a t -> bool
val iter : (int -> 'a -> unit) -> 'a t -> unit
val map : ('a -> 'b) -> 'a t -> 'b t
val mapi : (int -> 'a -> 'b) -> 'a t -> 'b t
val fold : (int -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
val merge : ('a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t
merge f m1 m2
returns a map that binds every key k
that is
either bound in m1
or/and in m2
.
If k
was bound to d1
in m1
and d2
in m2
, it is now bound to f d1 d2
.
If k
was bound to d1
in m1
but is not bound in m2
, it is still
bound to d1
.
If k
was bound to d2
in m2
but is not bound in m1
, it is still
bound to d2
.
Precondition on f
: if d1
equals d2
, f d1 d2
is supposed to return d1
.
val merge_first : 'a t -> 'a t -> 'a t
merge_first m1 m2
is the same as merge (fun a _ -> a) m1 m2
but it
reuses more data from the first map.
val diff : ('a -> 'a -> bool) -> 'a t -> 'a t -> 'a t
val choose_and_remove : 'a t -> int * 'a * 'a t
choose_and_remove t
returns (i,d,t') such that t'
equals to
remove i t
and d
equals to find i t
.
Not_found
if t
is empty.val inter : 'a t -> 'a t -> 'a t
inter m1 m2
returns a map with all the bindings (k,d)
of m1
such
that mem k m2
.
val inter_map2 : ('a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t
val keys_subset : 'a t -> 'a t -> bool
keys_subset m1 m2
returns true
if the set of keys in m1
is a subset of
the set of keys in m2
, false
otherwise.
val subset : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
subset sub m1 m2
returns true
if the set of keys in m1
is a subset of
the set of keys in m2
, and if for all value v1
in m1
, and v2
in m2
,
at the same position, sub v1 v2=true
holds,
false
otherwise.
val cardinal : 'a t -> int
val exists : (int -> 'a -> bool) -> 'a t -> bool
val filter : ('a -> bool) -> 'a t -> 'a t
val filteri : (int -> 'a -> bool) -> 'a t -> 'a t
val filter_map : ('a -> 'b option) -> 'a t -> 'b t
val partition : ('a -> bool) -> 'a t -> 'a t * 'a t
val elements : 'a t -> (int * 'a) list
elements m
return the unsorted list of bindings of m
.