English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Hashtbl and destructive operations on keys
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-03-23 (09:14)
From: Correnson_Loïc <Loic.Correnson@t...>
Subject: Re: [Caml-list] Hashtbl and destructive operations on keys
Notice also that implementing your own hashtbl would not be so far
For your dedicated use, the code for hashing and replacing this key to that
value would not exceed 10 lines,
assuming you can reuse Ocaml's hashing function and implements hash
collision with a simple array and associative lists.

Instead, your *codes* to work around Hashtbl with or without references may
never answer your question and will remain actually under specified and
fragile for your own purpose. Moreover, it is clear in your case that the
capability for ocaml hash tables to register several values for one key is
useless, since your always use replace and never add for existing key. To
finish with, your work-around code uses 3 times the hashtbl functions, hence
you hash the key 3 times. This is incompatible with looking for performance!

In my opinion, libraries always provide correct implementation for
prototyping or for reference implementation (e.g. for testing purpose).
However, ocaml library are always highly performant for normal use, and this
is why programming with ocaml is efficient.
Then, when facing a very low level performance constraint -- which in my
opinon should be exhibit first -- , one must look for a dedicated
implementation and not spent time in work arounf existing stuff.

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