From: Alex Baretta <alex@barettadeit.com>
To: Wheeler Ruml <ruml@parc.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Hashtbls with physical equality?
Date: Mon, 15 Nov 2004 11:24:35 +0100 [thread overview]
Message-ID: <419883E3.9040805@barettadeit.com> (raw)
In-Reply-To: <16792.4688.306149.402656@katsura.parc.xerox.com>
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/>
next prev parent reply other threads:[~2004-11-15 10:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-14 22:29 Wheeler Ruml
2004-11-15 0:33 ` [Caml-list] " Christian Szegedy
[not found] ` <20041115012212.GA6561@artisan.com>
2004-11-15 2:20 ` Wheeler Ruml
2004-11-15 10:24 ` Alex Baretta [this message]
2004-11-15 16:45 ` Wheeler Ruml
2004-11-15 20:34 ` Marcin 'Qrczak' Kowalczyk
2004-11-15 20:37 ` Brian Hurt
2004-11-15 21:03 ` Wheeler Ruml
2004-11-15 21:30 ` Marcin 'Qrczak' Kowalczyk
2004-11-15 23:42 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=419883E3.9040805@barettadeit.com \
--to=alex@barettadeit.com \
--cc=caml-list@yquem.inria.fr \
--cc=ruml@parc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox