English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Q: automatic forgetting cache, module Weak, Gc control
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-07-01 (18:13)
From: Alex Baretta <alex@b...>
Subject: Re: [Caml-list] Re: Q: automatic forgetting cache, module Weak, Gc control
Jan Kybic wrote:

> I am also thinking about other strategies taking into account the
> sizes of the produced results. In this case the global structure would
> be an ordered set.
> 
> The disadvantage of putting the values into two structures is the
> memory overhead. Maybe I should avoid using Weak hashtables
> alltogether and store the values in a set of normal hashtables,
> dropping some of them, if necessary... It is difficult to get the
> memory/speed tradeoff right.

You can memoize your results in a generic manner through the use of maps 
which use result hashes as keys. Two results hashing down to the same 
value will not be stored in the same map. The number of significant bits 
used by the hash function determines the size of the map.

Alex

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners