From: "Till Varoquaux" <till.varoquaux@gmail.com>
To: "Florent Monnier" <fmonnier@linux-nantes.fr.eu.org>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Hashtbl.remove legal within Hashtbl.iter for the same hash table?
Date: Sun, 11 May 2008 23:45:21 +0100 [thread overview]
Message-ID: <9d3ec8300805111545y34eccd27mb00187f23e779610@mail.gmail.com> (raw)
In-Reply-To: <200805111710.06994.fmonnier@linux-nantes.fr.eu.org>
Indeed. The answer you got was, however, based on the actual
implementation not on the documentation. This means that, at some
point, this might evolve and not be valid anymore. If you want to be
on the safe side you should do a fold instead of an iter and collect
all of the items to remove and then remove them in a second pass. The
performance hit shouldn't be as bad as you could expect (ie: I
wouldn't bother unless performance really is critical).
I see it as very unlikely that ocaml's implementation of hashtbl would
evolve in such a way that it would break any code removing previously
visited items during a traversal. Your call.
Till
On 5/11/08, Florent Monnier <fmonnier@linux-nantes.fr.eu.org> wrote:
>> Hatables are arrays of associative lists. When you are iterating over
>> them removing any element you have already visited should be ok.
>> Removing elements you haven't visited yet could cause you to encounter
>> them anyhow.
>
> which means that it is dependent to the order in which the content is
> itered,
> while the manual says :
> "The order in which the bindings are passed to f is unspecified."
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
--
http://till-varoquaux.blogspot.com/
next prev parent reply other threads:[~2008-05-11 22:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-11 9:20 David MENTRE
2008-05-11 14:42 ` [Caml-list] " Florent Monnier
2008-05-11 14:46 ` Till Varoquaux
2008-05-11 15:10 ` Florent Monnier
2008-05-11 22:45 ` Till Varoquaux [this message]
2008-05-11 23:08 ` Martin Jambon
2008-05-12 9:29 ` David MENTRE
2008-05-11 15:07 ` Florent Monnier
2008-05-11 14:44 ` Julien Peeters
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=9d3ec8300805111545y34eccd27mb00187f23e779610@mail.gmail.com \
--to=till.varoquaux@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=fmonnier@linux-nantes.fr.eu.org \
/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