On 2007-12-10 08:19:27 -0500,

ke****@gmail.com said:

I'd like to test if two sorted vectors intersect each other. What is

the most efficient implementation for this? I could calculate the

intersection but that would not be efficient since after finding only

one element in the intersection the algorithm should stop. I am

looking for something like the includes function.

Seems straightforward: start at the beginning of each sequence. If the

two elements are equal, you're done. If not, move forward in the

sequence that holds the lesser of the two elements. If you reach the

end of the sequence, you're done. Otherwise, repeat.

--

Pete

Roundhouse Consulting, Ltd. (

www.versatilecoding.com) Author of "The

Standard C++ Library Extensions: a Tutorial and Reference

(

www.petebecker.com/tr1book)