Browse thread
Hashtbls with physical equality?
[
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: | 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 Alex -- ********************************************************************* http://www.barettadeit.com/ 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) <http://www.asxcaml.org/> The FreerP Project <http://www.freerp.org/>