From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA25620; Mon, 27 May 2002 16:39:02 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA25420 for ; Mon, 27 May 2002 16:39:02 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g4REcrD28953; Mon, 27 May 2002 16:38:53 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA25580; Mon, 27 May 2002 16:38:53 +0200 (MET DST) Date: Mon, 27 May 2002 16:38:53 +0200 From: Xavier Leroy To: John Max Skaller Cc: caml-list@inria.fr Subject: Re: [Caml-list] Hashtbl iter semantics Message-ID: <20020527163853.A25103@pauillac.inria.fr> References: <3CF102B3.7030200@ozemail.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <3CF102B3.7030200@ozemail.com.au>; from skaller@ozemail.com.au on Mon, May 27, 2002 at 01:43:47AM +1000 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Could the ocaml team please clarify the semantics of Hashtbl.iter? > In particular, can I use Hashtbl.replace during iteration? > [What about add, removed, etc?] You can use Hashtbl.{replace,add,remove} while iterating over the same hash table, in the sense that it will not corrupt the table. However, there is no guarantee that the iteration will "see" the modification or not. E.g. if you add an element, the function being iterated can be called on the newly added element, or not, depending on the relative positions of the new element and of the iteration point inside the hash table. If you need stronger guarantees (e.g. the iteration must operate on the initial state of the table), consider replacing the hash table by a reference to a binary tree (module Map). - Xavier Leroy ------------------- 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