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 (10:22)
From: Alex Baretta <alex@b...>
Subject: Re: [Caml-list] Hashtbls with physical equality?
Wheeler Ruml wrote:
>>>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

Keep in mind that the hash function in the Hashtbl.Make functor can be 
any function whose signature is t -> int. This allows you to tweak and 
twine your hashing algorithm as you choose. If you don't want to right a 
hashing algorithm from scratch, than parametrize Xavier's to your 
heart's content:

val hash_param : int -> int -> 'a -> int


Baretta DE&IT
A division of Baretta SRL

tel. 02 370 111 55
fax. 02 370 111 54

Our technology:

The Application System/Xcaml (AS/Xcaml)

The FreerP Project