On 11/03/13 21:55, Ryan wrote:
I probably didn't described very well what I wanted in the first
place. All the objects in those lists contain an "id" property which
has a unique value. I am trying to find out, which objects from the
first list, based on that "id" property, are not included in list b.
If those objects override .equals() properly then I presume it would
work just fine calling removeAll() and relying on the Collections
framework which will eventually call .equals(). Do you own those
objects? Is the 'id' field declared final and is it involved in the
corresponding .equals() methods? Are those objects inheriting stuff?
there are so many things that can go wrong when you start to wonder
about object equality...
if performance is not critical to your problem you could create
intermediate records/maps , do your logic safe and concise, get the ids
you want and go find the original objects these ids belong to...in fact
you can attach those objects as meta-data to save yourself the hassle!
;;not tested but seems reasonable!
(defrecord TEMP [id])
(def step1
(clojure.set/difference
(set (map #(TEMP. (.getId %) {:ob %} nil) java-util-list-with-objects1))
(set (map #(TEMP. (.getId %) {:ob %} nil)
java-util-list-with-objects2)) ) ) ;;half way there
(def step2
(for [t step1]
(-> t meta :ob)))
;;not tested but seems reasonable doesn't it?
hope that helps...
Jim
ps: now that I look at it maybe a map (with 2 keys :id :ob) seems a
simpler choice...
--
--
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
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.