module Memo:Bounded-size memoization tables
'ato values of type
val create :
int -> ('a, 'b) t
create ncreates a new memoization table with
val get :
('a, 'b) t -> ('a -> 'a -> bool) -> 'a -> int -> 'b Lazy.t -> 'b
get tbl cmp x i vtries to fetch a previously computed value for the key
xin the table
tblin the slot
i. If the result is not available in the table, the result is computed by forcing the lazy argument v. It may be kept it in the table for a later call. This is the case in particular if the slot
iwas empty. Otherwise, the decision to keep the value for old key or to reuse the slot for the key
xis not specified.
The current implementation, however, is such that, if we consider the sequence of all the calls for a given slot, and if one the keys appears strictly more often than half of the time in this sequence, then this key "wins": its result is the one which is kept in the table.
Keys are compared for equality using the function
val clear :
('a, 'b) t -> unit
clear tblremoves all the keys and the associated values from the table.