module Bounded_int_table: Bounded_int_table
type ('key, 'data)
t
type('a, 'b)
table =('a, 'b) t
include Equal.S2
val invariant : ('a, 'b) t -> unit
val create : ?sexp_of_key:('key -> Std_internal.Sexp.t) ->
num_keys:int ->
key_to_int:('key -> int) -> unit -> ('key, 'data) t
create ~num_keys ~key_to_int
returns a table where the keys can map to 0
.. num_keys-1, according to key_to_int
. It is an error if num_keys < 0
.
sexp_of_key
, if supplied, will be used to display keys in error messages.
val keys : ('key, 'a) t -> 'key list
val data : ('a, 'data) t -> 'data list
val find : ('key, 'data) t -> 'key -> 'data option
val find_exn : ('key, 'data) t -> 'key -> 'data
val find_or_add : ('key, 'data) t -> 'key -> default:(unit -> 'data) -> 'data
val fold : ('key, 'data) t ->
init:'accum -> f:(key:'key -> data:'data -> 'accum -> 'accum) -> 'accum
val iter : ('key, 'data) t ->
f:(key:'key -> data:'data -> unit) -> unit
val iter_vals : ('a, 'data) t -> f:('data -> unit) -> unit
val filter_mapi : ('key, 'data1) t ->
f:(key:'key -> data:'data1 -> 'data2 option) ->
('key, 'data2) t
val filter_map : ('key, 'data1) t ->
f:('data1 -> 'data2 option) -> ('key, 'data2) t
val mapi : ('key, 'data1) t ->
f:(key:'key -> data:'data1 -> 'data2) -> ('key, 'data2) t
val map : ('key, 'data1) t ->
f:('data1 -> 'data2) -> ('key, 'data2) t
val for_alli : ('key, 'data) t ->
f:(key:'key -> data:'data -> bool) -> bool
val existsi : ('key, 'data) t ->
f:(key:'key -> data:'data -> bool) -> bool
val for_all : ('a, 'data) t -> f:('data -> bool) -> bool
val exists : ('a, 'data) t -> f:('data -> bool) -> bool
val length : ('a, 'b) t -> int
val mem : ('key, 'a) t -> 'key -> bool
val remove : ('key, 'a) t -> 'key -> unit
val set : ('a, 'b) t -> key:'a -> data:'b -> unit
val add : ('a, 'b) t ->
key:'a -> data:'b -> [ `Duplicate of 'b | `Ok ]
val add_exn : ('a, 'b) t -> key:'a -> data:'b -> unit
val to_alist : ('key, 'data) t -> ('key * 'data) list
module With_key:functor (
Key
:
sig
type
t
val to_int :t -> int
val t_of_sexp :Sexplib.Sexp.t -> t
val sexp_of_t :t -> Sexplib.Sexp.t
val bin_t :t Bin_prot.Type_class.t
val bin_read_t :t Bin_prot.Read_ml.reader
val bin_read_t_ :t Bin_prot.Unsafe_read_c.reader
val bin_read_t__ :(int -> t) Bin_prot.Unsafe_read_c.reader
val bin_reader_t :t Bin_prot.Type_class.reader
val bin_size_t :t Bin_prot.Size.sizer
val bin_write_t :t Bin_prot.Write_ml.writer
val bin_write_t_ :t Bin_prot.Unsafe_write_c.writer
val bin_writer_t :t Bin_prot.Type_class.writer
end
) ->
sig
..end
val debug : bool Pervasives.ref
debug := true
to turn on debugging, including potentially slow invariant
checking.val sexp_of_t : ('key -> Sexplib.Sexp.t) ->
('data -> Sexplib.Sexp.t) ->
('key, 'data) t -> Sexplib.Sexp.t
create ~num_keys ~key_to_int
returns a table where the keys can map to 0
.. num_keys-1, according to key_to_int
. It is an error if num_keys < 0
.
sexp_of_key
, if supplied, will be used to display keys in error messages.
Standard hashtbl functions.
Serialization of a bounded int table using bin_io
or sexp
preserves num_keys
,
but only takes space proportional to the length
of the table.
set debug := true
to turn on debugging, including potentially slow invariant
checking.