Here's the problem that I have:
I need to compare two ArrayLists and return if they are the same or if they are different, return the elements that are new from one of them, the pivot so to speak.
Here's the behaviour of the data-set:
- the two ArrayLists are made of Strings
- they're populated from the same source so are most of the time the same
- are ordered (in the sense of the custom logic attached to them)
- there will never be any empty Strings
- all of the Strings have the same length, always
- no duplicates
What I want:
- the fastest possible way of achieving my two goals, whichever the case
- using only Java 1.6 standard library features, I'd prefer not to implement a hybrid class that emulated something from List and then Set for example.
Example:
A: [ 'a', 'b', 'c', 'd']
B: [ 'a', 'c', 'd']
Result: Lists are different, return the element 'b'; A will be the 'work' List, we will make comparisons based on what's new in this ArrayList, since B will never change.
Thanks for any replies and your input.