On Feb 4, 5:33 am, Rich Hickey <richhic...@gmail.com> wrote: > On Feb 3, 10:44 pm, Jason Wolfe <jawo...@berkeley.edu> wrote: > > > This just bit me a second time, since one of my revised set functions > > uses "contains?" and thus doesn't work on java.util.Sets (or even > > the .keySets of Clojure maps). > > > user> (contains? (.keySet {:a :b}) :a) > > false > > > It seems that all that's required to make "contains?" work on general > > Sets is to replace "IPersistentSet" with "Set" on lines 648 and 649 of > > RT.java. I can make a patch if desired. > > Patch welcome - must handle both overloads of RT.get() - thanks! > > Rich
Hah, I'm not sure if you are serious or trying to get me to answer my own question ... either way, thanks :) I went to implement the RT.get() portion of this patch, and was very surprised to find that there seems to be no way to get "the [actual, identical?] object that is held in the set which compares equal to the key, if found" from a java.util.Set in sublinear time. You could use .contains and return "an object .equal to the object in the set, if found", but I suspect this is not what "get" is supposed to do. In this case, I guess there is good reason that "contains?" does not work on java.util.Sets :). Please correct me if I'm wrong on the contract of "get"; otherwise, I'll drop this. Thanks! Jason --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---