On Fri, Apr 30, 2010 at 4:33 AM, Rich Hickey <richhic...@gmail.com> wrote: > On Apr 29, 2010, at 4:21 AM, ataggart wrote: >> Functions named contains-key? and contains-val? would make a lot more >> sense to me than the current contains? and new seq-contains?. Anyone >> looking at contains-val? should expect it to be O(n). The only >> effective difference would be that the test value for contains-val? is >> consistently a single value rather than a [key value] tuple for maps. > > People don't consider sets, vectors, arrays or strings to have 'keys'. But, > like maps, they all support fast lookup of some sort.
Actually I do consider sets to have keys, since internally they are implemented using maps, so the exact same semantics apply for their lookup. They're just maps where the key and value are the same thing: protected APersistentSet(IPersistentMap impl){ this.impl = impl; } public boolean contains(Object key){ return impl.containsKey(key); } public Object get(Object key){ return impl.valAt(key); } Because of this I would also expect contains-val? to be constant-time for sets, so I think seq-contains? is a better name. Anyway, I'm a little weary of this discussion by now, (and I can't be the only one) so I'd be perfectly happy leaving things as they are. I am glad that a lot of thought goes into these names though; it definitely shows. -Phil -- 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