Consistent with equals and unique values in Set
So the other day one of my friends was trying to solve a problem and he decided to share his problem with me. So based on my understanding of what he was trying to do was, that he had 2 disparate groups of data stored in Lists, the two lists were likely to have duplicates. His objective was to consolidate the two lists such that the consolidated list would only have unique entries. The lists had custom data structures, so straightforward methods of adding elements to a Set by itself wasn't enough, nor was it the situation where you add all the elements to one big list and somehow use the removeAll method. My first reaction to this problem was, hmm why not exploit the consistent with equals concept with a Comparator . Now this may or may not be a good solution, it was a fun one for me to knock up and it builds on my last post about Sorting in Java. The problem Say we are getting two streams of data, which may or may not contain duplicates and our goal is to get data that is ...