module Literal_map:Maps keyed off literals.Index.Map
with type key = Literal.t
type
key
type 'a
t
0, ... ,n - 1
(where n
is the number of keys in
the map) to 'a
.val size : 'a t -> int
size m
is the number of indices mapped by m
.
size m >= 0
val create : 'a -> 'a t
create x
is a new, empty map. x
can be any element of type 'a
and is used only for initializing the underlying representation.val is_empty : 'a t -> bool
is_empty m
holds if the map is empty.
is_empty m = (size m = 0)
val mem : 'a t -> key -> bool
val find : 'a t -> key -> 'a
val add : 'a t -> key -> 'a -> unit
add m k x
modifies m
by mapping the index of k
to x
.
Any previously unmapped indices in 0, ..., index k
will also
be mapped to x
.
Index.Map.find
m k = x
val replace : 'a t -> key -> 'a -> unit
replace m k x
updates m
by mapping the index of k
to x
.
Index.Map.mem
m k
Index.Map.find
m k = x
val copy : 'a t -> 'a t
val iter : (key -> 'a -> unit) -> 'a t -> unit
iter f m
applies f
to all mappings in m
.val iter_const : ('a -> key -> 'b -> unit) -> 'a -> 'b t -> unit
val fold : ('a -> key -> 'b -> 'a) -> 'a -> 'b t -> 'a
fold f a m
applies f
to an accumulated value and each
key-value pair in the mapping m
.val fold_const : ('a -> 'b -> key -> 'c -> 'b) -> 'a -> 'b -> 'c t -> 'b
val modify : ('a -> 'a) -> 'a t -> unit
modify f m
modifies a map so that each index maps to f
of its
prior value.val modify_const : ('a -> 'b -> 'b) -> 'a -> 'b t -> unit
modify_const f x v
is modify (f x) v
, only faster since applying
closures is slow.val set_all : 'a t -> 'a -> unit
set_all m x
updates m
by mapping every key to x
.