Yes, the true/false for equality is not a problem. I am looking for a shortcut that finds different elements more efficiently. So, the sets are different, but I want to get hold of elements that are in s2 but not in s1.
On Dec 16, 8:38 pm, Richard Newman <holyg...@gmail.com> wrote: > > I imagine this is possible if you drill into the guts of > > PersistentHaspMap, but I would strongly discourage the behavior in > > user code. Perhaps as an upgrade to the object itself? There is a 1% > > chance that this could be a language upgrade, assuming it works across > > the board. I would tread cautiously. > > I could easily imagine an implementation of equality for two tree sets > checking for intermediate node reference equality as a shortcut... but > as you say, not in user code. > > Right now, APersistentSet.equals(Object o) only casts to Set, and does > equality checking by iterating over the elements of the input set. > > I'd certainly benchmark this before doing the work, though -- I'd > guess that most equal sets will hash-compare as equal, most non-equal > sets will fail early on in a per-element comparison, and it's probably > a minority of compared sets that will share structure. It's unlikely > that adding an additional object identity comparison is worth the > machine instructions. > > My hunch (from examining the performance of Clojure's sets in the > past) is that it's not worth doing the work... -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en