From: Brighten Godfrey <pbg@cs.berkeley.edu>
To: blue storm <bluestorm.dylc@gmail.com>,
Chris Kauffman <kauffman@cs.umn.edu>,
peng.zang@gmail.com
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Getting an element of a hashtable: simple ... or is it?
Date: Tue, 5 Aug 2008 14:47:37 -0700 [thread overview]
Message-ID: <E6024C49-8B6D-43ED-B622-3D003CF81AEE@cs.berkeley.edu> (raw)
In-Reply-To: <527cf6bc0808050525x5d574e5ek4b7acbc4e114307e@mail.gmail.com>
On Aug 5, 2008, at 5:25 AM, blue storm wrote:
> With Extlib you can use :
> let get_one hashtbl = Enum.peek (Hashtbl.enum hashtbl)
> val get_one : ('a, 'b) Hashtbl.t -> ('a * 'b) option
Ah, thanks.
On Aug 5, 2008, at 6:21 AM, Peng Zang wrote:
> I think this is pretty standard. At least, I see it in ExtLib and
> I do it on
> a regular basis. In fact I have a function to do this for me so I
> don't have
> to do it over and over again. Eg.
>
> let get_one ht = mkGetOne Hashtbl.iter ht
OK -- so you're saying ExtLib also implements it by breaking out of
the loop with an exception. Interesting.
On Aug 5, 2008, at 2:02 PM, Chris Kauffman wrote:
> I'm curious what sort of scenario calls for retrieving any single
> element of a hash table (which is potentially empty?). It seems most
> of the cases I deal with involve simply storing or iterating over all
> the elements.
Yes, nearly all cases are like that for me too. But in this case, I
want to decompose a graph into its connected components, roughly
according to the following pseudocode:
unprocessed_nodes : (node_t, unit) Hashtbl.t = all nodes
while unprocessed_nodes not empty do
let one_node = choose any one node from unprocessed_nodes
let cc = find_connected_component_containing one_node
Do some sort of processing on cc. Then:
for each node v in cc
remove v from unprocessed_nodes
done
Thanks,
~Brighten Godfrey
next prev parent reply other threads:[~2008-08-05 21:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-05 12:05 Brighten Godfrey
2008-08-05 12:16 ` [Caml-list] " Richard Jones
2008-08-05 12:26 ` Brighten Godfrey
2008-08-05 12:25 ` blue storm
2008-08-05 21:47 ` Brighten Godfrey [this message]
2008-08-08 15:46 ` Ludovic Coquelle
2008-08-08 16:01 ` Peng Zang
2008-08-05 13:21 ` Peng Zang
2008-08-05 21:02 ` Chris Kauffman
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=E6024C49-8B6D-43ED-B622-3D003CF81AEE@cs.berkeley.edu \
--to=pbg@cs.berkeley.edu \
--cc=bluestorm.dylc@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=kauffman@cs.umn.edu \
--cc=peng.zang@gmail.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