I've got two lists:
List x = [1, 2, 5, 7, 8];
List y = [1, 3, 4, 5];
I'm trying to get the following calculated asymmetric differences:
x - y (what's in x that's not in y) => 2 7 8
y - x (what's in y that's not in x) => 3 4
I've already checked some pointers on this and this, but I have some constraints on my back:
What I'm trying to implement is exactly what guava's Sets.difference offers, except I'm stuck with Java 1.4 (I'm easily able to change my implementation from using Lists to Sets)
Using Collection.removeAll/retainAll would be a deal breaker, as those methods work in-place. The objects I'm holding in the lists are some heavyish POJOS that are actually mapped to Hibernate.
- In this sense, I need something that should work out of a hash-based implementation, as this calculation is already implemented in those POJOS.
Bottom line is, is there anything like Sets utility class for Java 1.4? Or something that could calculate the asymmetric difference of two collections?