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 00D57BD1E for ; Mon, 15 Nov 2004 22:03:30 +0100 (CET) Received: from alpha.xerox.com (alpha.Xerox.COM [13.1.64.93]) by nez-perce.inria.fr (8.13.0/8.13.0) with SMTP id iAFL3OS6029880 for ; Mon, 15 Nov 2004 22:03:29 +0100 Received: from katsura.parc.xerox.com ([13.2.18.21]) by alpha.xerox.com with SMTP id <149776(2)>; Mon, 15 Nov 2004 13:03:09 PST Received: (from ruml@localhost) by katsura.parc.xerox.com (8.12.8/8.12.8/PARC RedHat Custom Submit 1.3) id iAFL38YU002958; Mon, 15 Nov 2004 13:03:08 -0800 From: Wheeler Ruml MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16793.6540.701268.314718@katsura.parc.xerox.com> Date: Mon, 15 Nov 2004 13:03:08 PST To: Brian Hurt Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Hashtbls with physical equality? In-Reply-To: References: <16791.56417.334890.765954@katsura.parc.xerox.com> X-Mailer: VM 7.07 under 21.4 (patch 12) "Portable Code" XEmacs Lucid X-Miltered: at nez-perce with ID 4199199C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; wheeler:01 caml-list:01 ocaml:01 hash:01 hash:01 traversing:01 integers:01 wheeler:01 ...:98 ...:98 alto:98 equality:01 strings:01 integer:01 explicitly:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: Hi Brian, Thanks for your reply. > > Is it possible in OCaml to have a hash table that can insert and retrieve > > values without walking over their structure? I tried to hack something > > together using Obj.magic > > There is no magic value associated with objects, unlike Java. OK - thanks. > > I have a hash table > > of strings and I'd like to avoid traversing their length on every lookup. > > Do I have to explicitly use integers instead? > > [...] I think what you're asking for is impossible. Yeah, seems that way. I think I'll explicitly associate an integer with each string, along the lines of what you suggest. > The nice thing about balanced trees is that they're O(log N) worst case. > [...] Getting it working first, then worry about performance. Thanks for the tips - good advice. Happily, it already works, and a factor of two in performance actually does matter in my application. Best, 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