If I have a variable number of sets (let\'s call the number n), which have at most m elements each, what\'s the most efficient way to calculate the pairwise in
If we can assume that the input sets are ordered, a pseudo-mergesort approach seems promising. Treating each set as a sorted stream, advance the streams in parallel, always only advancing those where the value is the lowest among all current iterators. Compare each current value with the new minimum every time an iterator is advanced, and dump the matches into your same-item collections.