I have two lists (structure undecided), each contains column A and column B. I primarily need to know which elements of column A in list1 are missing in list 2 column A, or which ones in list2 column A are missing from list1 column A. I have no idea where to begin here. Of course a nested loop could achieve it, but there must be some elegant method.
THEN, for those matches where list1colA==list2colA, I also need to know whether or not list1colB==list2colB. I figure once the first question is answered, a single loop can determine this part, but if it can be combined with the above, that would be even better.
so for example, an ID and a timestamp for colA and colB
list 1:
Code:
col A colB
0 7:35
1 6:03
3 15:07
4 16:58
list2:
Code:
colA colB
0 7:35
1 8:19
2 3:02
4 16:58
So somehow it would know that colA=colA on 0,1,4, but timestamps are different on 1, and also that list2 has an extra#2 and list1 has an extra#3.
Just a nudge in the right direction is all I need.
Well, you could use std::set_difference() to find which elements are in one but not the other. However, that would require you to sort the inputs first. Just about every "elegant" method either requires you to sort or hash the inputs.
hmm. If theyre already sorted I could just do one pass through the lists and find the missing and extra and different_colB items. Would that be faster than a two pass set_difference?
Bookmarks