Browse thread
Getting an element of a hashtable: simple ... or is it?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Richard Jones <rich@a...> |
| Subject: | Re: [Caml-list] Getting an element of a hashtable: simple ... or is it? |
On Tue, Aug 05, 2008 at 05:05:46AM -0700, Brighten Godfrey wrote: > Suppose you are given a data structure, and you want to retrive one > element -- any one element. Sounds simple... and it is, if you have > a list (List.hd list) or an array (arr.(0)). But how about a > hashtable, if we don't know a priori any of the keys in the hashtable? It's very unclear what you're trying to do. For List and Array those methods won't work if the data structure is empty, but I guess that's expected. Hashtbl isn't designed with the "get an/any element" usage in mind -- your loop/exception is probably the best way given that you've made a poor choice of data structure in the first place. But this still comes back to the question, what are you trying to do? Rich. -- Richard Jones Red Hat