Am Mittwoch, den 10.09.2014, 08:40 -0400 schrieb Nick Lucaroni > On Sep 10, 2014 8:27 AM, "Gerd Stolpmann" > 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 ------------------------------------------------------------