caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christophe Raffalli <raffalli@univ-savoie.fr>
To: Dave Mason <dmason@sarg.ryerson.ca>
Cc: Charles Martin <joelisp@yahoo.com>, caml-list@inria.fr
Subject: Re: [Caml-list] Weak hash table
Date: Wed, 06 Mar 2002 11:09:21 +0100	[thread overview]
Message-ID: <3C85EAD1.8316BE37@univ-savoie.fr> (raw)
In-Reply-To: <200203052224.g25MOFF16528@sarg.ryerson.ca>

Dave Mason a écrit :
> 
> A while ago I bugged Xavier about this.  He agreed it would be nice to
> have weak hash tables, so if anyone volunteered an implementation, I
> suspect it would quickly make its way into the standard library.
> 
> I haven't thought hard about it, but I think it needs some additional
> hooks in the garbage collector.  (Without even *considering* the whole
> heirarchy of weakness in Java!)
> 
> ../Dave

If you want key or value weak hashtable (that is entry are kept in the
hash table is the key of the value 
are pointed from somewhere outside the hashtable), it can be done with
just the Weak module
of Caml (you can almost do it by regexp query replace in hashtbl.ml). 

If you just want value (resp. key) weak hashtable (that is entry are
kept in the hash table if the value 
is pointed from somewhere outside the hashtable), It is possible also,
you just need to do a shallow copy of the key (resp. the value) before
insertion in the table. If you do not want to loose a little memory, you
need help from the GC.

Anyway if your key are integers or floats both are equivalent !

if you key are strings possibly long, the cost of shallow copy may be a
problem.

Just one trouble: if you want hashtabl with unique key all this is true.

If you want hashtable with multiple key (as in module Hashtbl) you need
a weak array of weak array ... it starts
to be a bit complex and may be help from the GC would be useful to get a
nicer code.

-- 
Christophe Raffalli
Université de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tél: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
-------------------
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


  reply	other threads:[~2002-03-07  9:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-15  1:48 [Caml-list] Another q about many types Ryan Tarpine
2002-04-15  8:06 ` Christian Gillot
2002-03-05 16:28   ` [Caml-list] Weak hash table Christophe Raffalli
2002-03-05 21:40     ` Charles Martin
2002-03-05 22:24       ` Dave Mason
2002-03-06 10:09         ` Christophe Raffalli [this message]
2002-03-06 10:39         ` Christophe Raffalli
2002-03-06  8:33     ` Jean-Christophe Filliatre
2002-03-06 12:50 Damien Doligez
2002-03-06 13:40 ` Remi VANICAT
2002-03-14 14:09 Damien Doligez
2002-03-15  1:49 ` Brian Rogoff
2002-03-14 14:16 Damien Doligez
2002-03-22 14:15 Damien Doligez
2002-03-22 18:35 [Caml-list] Weak Hash table Remi VANICAT

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3C85EAD1.8316BE37@univ-savoie.fr \
    --to=raffalli@univ-savoie.fr \
    --cc=caml-list@inria.fr \
    --cc=dmason@sarg.ryerson.ca \
    --cc=joelisp@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).