Fastest way to get different elements between vectors

I have 2 vectors which I'd like to retrieve different members as such:

1
2
(in_vec1 && not_in_vec2)
(in_vec2 && not_in_vec1)


Performance is a concern so I don't want to iterate through both vectors, twice. Any suggestions?
http://en.cppreference.com/w/cpp/algorithm/set_difference

Requires that the elements are ordered. If not, the vectors have to be sorted first ( O( N * log(N) ) ).
Thanks I'll implement and use that one.
Topic archived. No new replies allowed.