From: Nicolas C. <war...@fr...> - 2005-05-07 07:03:21
|
> > Dear Ext-lib developers, > > > > This tiny module: > > http://www.eleves.ens.fr/home/frisch/soft.html#memo > > > > implements memoization tables with bounded size. Such a table can be > > used to memoize a function without using a lot of memory. A hash > > function is used to retrieve a previously computed value for a given > > key. The implementation uses a nice and simple heuristic to choose what > > to do in case of collision on the hash value for two keys. > > > > Feel free to add this module to ext-lib if you think it can be useful. > > On a related topic: the Hashtbl module > Would it be a good thing to add functions which do not require to > recompute the hashed key (with Hashtbl.hash), for efficiency purposes: > > val unsafe_find : ('key, 'data) t -> int -> 'key -> 'data > val unsafe_mem : ('key, 'data) t -> int -> 'key -> bool > val unsafe_add : ('key, 'data) t -> int -> 'key -> 'data -> unit This require a lot of "unsafe" functions, and actually they are not "unsafe" at all :) The best way to enforce that is to use a (int,'a) Hashtbl.t and hash your values by hand when needed. Nicolas |