From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 7663BBB81 for ; Mon, 15 Nov 2004 11:22:22 +0100 (CET) Received: from alex.barettalocal.com (h213-255-109-130.albacom.net [213.255.109.130] (may be forged)) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iAFAMLvw016523 for ; Mon, 15 Nov 2004 11:22:22 +0100 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by alex.barettalocal.com (Postfix) with ESMTP id 3FA262BAA6D; Mon, 15 Nov 2004 11:24:35 +0100 (CET) Message-ID: <419883E3.9040805@barettadeit.com> Date: Mon, 15 Nov 2004 11:24:35 +0100 From: Alex Baretta User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913 X-Accept-Language: it, en-us, en MIME-Version: 1.0 To: Wheeler Ruml Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Hashtbls with physical equality? References: <16791.56417.334890.765954@katsura.parc.xerox.com> <20041115012212.GA6561@artisan.com> <16792.4688.306149.402656@katsura.parc.xerox.com> In-Reply-To: <16792.4688.306149.402656@katsura.parc.xerox.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4198835D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; baretta:01 caml-list:01 wheeler:01 wrote:01 ocaml:01 hash:01 hashtbl:01 struct:01 hash:01 hashtbl:01 bounded:01 wheeler:01 functor:01 tweak:01 hashing:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.0 X-Spam-Level: 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) The FreerP Project