Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Wheeler Ruml <ruml@p...>
Subject: Re: [Caml-list] Hashtbls with physical equality?
> > Is it possible in OCaml to have a hash table that can insert and retrieve
> > values without walking over their structure?
> 
> How about something like this?
> 
> module PhysrefHashtbl =
>   Hashtbl.Make (struct type t = string
>     let equal = (==)
>     let hash = Hashtbl.hash
>   end)

My only concern about this solution is that Hashtbl.hash will walk over the
key's structure in order to compute its hash value.  I know that its
computation is bounded, but I'd still love to find something faster and
more more direct if possible.

Thanks,

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