Imagine a vector of structures with each structure containing various variables.
//input some data from a file into DataSet
How can I iterate over this vector, comparing say, x at the nth row to the x at the (n-1th) row and the x at the (n-2th) row, beginning at n (where n is Dataset.begin() + 2) and moving one n forward at a time?
So start at Dataset.begin() + 2, increment your iterator while it's not equal to Dataset.end() as usual, and just refer to the iterators (it - 1) and (it - 2) in your loop.
You could also start with three iterators pointint at Dataset.begin(), Dataset.begin() + 1, and Dataset.begin() + 2, and increment them all, using the last one to control the loop. It seems like this might get you a performance improvement, but I'm not 100% sure about that. At the moment, I prefer the first approach; I consider it more readable.