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
Hashtbls with physical equality?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-11-15 (21:03)
From: Wheeler Ruml <ruml@p...>
Subject: Re: [Caml-list] Hashtbls with physical equality?
Hi Brian,

Thanks for your reply.

> > Is it possible in OCaml to have a hash table that can insert and retrieve
> > values without walking over their structure?  I tried to hack something
> > together using Obj.magic
> There is no magic value associated with objects, unlike Java.

OK - thanks.

> > I have a hash table
> > of strings and I'd like to avoid traversing their length on every lookup.
> > Do I have to explicitly use integers instead?
> [...] I think what you're asking for is impossible.

Yeah, seems that way.  I think I'll explicitly associate an integer with
each string, along the lines of what you suggest.

> The nice thing about balanced trees is that they're O(log N) worst case.
> [...]  Getting it working first, then worry about performance.

Thanks for the tips - good advice.  Happily, it already works, and a factor
of two in performance actually does matter in my application.


Wheeler Ruml, Palo Alto Research Center, Rm 1522, 650-812-4329 voice
ruml@parc.com, http://www.parc.com/ruml           650-812-4334 fax