Browse thread
[Caml-list] Should be INSIDE STANDARD-LIB: Hashtbl.keys
[
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: | John Goerzen <jgoerzen@c...> |
| Subject: | Re: [Caml-list] Should be INSIDE STANDARD-LIB: Hashtbl.keys |
On Fri, Apr 23, 2004 at 09:10:11PM +0200, Oliver Bandel wrote: > On Fri, Apr 23, 2004 at 01:29:06PM -0500, John Goerzen wrote: > > On Fri, Apr 23, 2004 at 02:51:41PM +0200, Xavier Leroy wrote: > > > With your specification (no repetitions in the list), that function > > > would run in quadratic time, which is a sure sign that lists aren't > > > the right data structure here. (More generally speaking, "lists > > > without repetitions" is almost always the wrong data structure.) > > > > But perhaps you don't really care how fast it runs, since your entire > > program consumes about 1/10 of a CPU second anyway? > > Depends on number of keys... > > n ^ 2 is less when n is low, > n = 10 and n = 10000 seems not to matter much... > but 10^2 and 10000^2 are a differrence that matters a lot! OK, but why should we eliminate a useful function because 1% of uses of it will be slow? Make a note in the docs (like that notes that are there already that say "this function is not tail-recursive") and put it in for those that will find it useful. On another note, I really don't understand why hashtables permit duplicate keys anyway; it just doesn't seem useful to me. All my Hashtbl code uses Hashtbl.replace.... -- John ------------------- 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