Bounded_int_table is a table whose keys can be mapped to integers in a fixed
range, 0 ... num_keys-1, where
num_keys is specified at table-creation time. The
Bounded_int_table is to be faster than
Hashtbl in situations where one
is willing to pay a space cost for the speed.
Bounded_int_table presents a subset of the
Hashtbl interface. The key type can be
any type, but table creation requires a
key_to_int function, which will be used
to extract the integer of all keys. If multiple keys map to the same integer, then
only one of them can be in the table at a time. Any operation that supplies a key
whose corresponding integer is outside the allowed range for the table will cause an
Bounded_int_table is implemented using two fixed size arrays of size
which are supplied at table-creation time. The space used does not depend on the
length of the table but rather only on
num_keys. Operations that deal with a
single element (find, mem, add, remove, set) take constant time, and perform one or
two array operations. Operations that deal with all of the keys defined in the table
(data, fold, iter, iter_vals, keys, to_alist) take time proportional to the
of the table, not
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.
debug := true to turn on debugging, including potentially slow invariant