From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: Nick Lucaroni <nicholas.r.lucaroni@gmail.com>
Cc: Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Clarification for the configuration of comparison functions
Date: Wed, 10 Sep 2014 14:44:22 +0200 [thread overview]
Message-ID: <1410353062.3003.23.camel@thinkpad> (raw)
In-Reply-To: <CAADdkeKquMWyHjQhgd2SOZYr9DaS2E+i3Ug5=xb25BK-+n16eQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1182 bytes --]
Am Mittwoch, den 10.09.2014, 08:40 -0400 schrieb Nick Lucaroni
> On Sep 10, 2014 8:27 AM, "Gerd Stolpmann" <info@gerd-stolpmann.de>
> wrote:
> > There is something else that can speed up a custom compare: you can
> also
> > store a hash of the value inside the value, and use that for
> speeding up
> > comparison, e.g.
> >
> > type t = ...
> > type t_cmp = t * int
> >
> > let wrap x = (x, Hashtbl.hash x)
> >
> > let my_compare (x1,h1) (x2,h2) =
> > if h1=h2 then
> > compare x1 x2
> > else
> > h1-h2
>
> The hash difference here would cause issues, is it really worth it if
> you have to recover some ordering anyway? I can see the value in
> defining equality, though.
For example, if you need the ordering only for a Map or Set, it doesn't
matter how things are ordered.
Gerd
--
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de
My OCaml site: http://www.camlcity.org
Contact details: http://www.camlcity.org/contact.html
Company homepage: http://www.gerd-stolpmann.de
------------------------------------------------------------
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2014-09-10 12:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-10 8:56 SF Markus Elfring
2014-09-10 11:27 ` Gerd Stolpmann
2014-09-10 12:07 ` Yotam Barnoy
2014-09-10 12:26 ` Gerd Stolpmann
2014-09-10 12:37 ` Adrien Nader
2014-09-10 12:38 ` Yotam Barnoy
2014-09-10 12:41 ` Pippijn van Steenhoven
2014-09-10 12:51 ` Gerd Stolpmann
2014-09-10 12:56 ` Ben Millwood
[not found] ` <CAADdkeKquMWyHjQhgd2SOZYr9DaS2E+i3Ug5=xb25BK-+n16eQ@mail.gmail.com>
2014-09-10 12:44 ` Gerd Stolpmann [this message]
2014-09-10 20:56 ` SF Markus Elfring
2014-09-11 7:46 ` Francois Berenger
2014-09-11 8:10 ` SF Markus Elfring
2014-09-11 8:24 ` Francois Berenger
2014-09-11 8:33 ` SF Markus Elfring
2014-09-11 8:39 ` Frédéric Bour
2014-10-06 20:50 ` SF Markus Elfring
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=1410353062.3003.23.camel@thinkpad \
--to=info@gerd-stolpmann.de \
--cc=caml-list@inria.fr \
--cc=nicholas.r.lucaroni@gmail.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