How about a loop through your matrix, checking every 2.nd dimension item up against your comparison 2.nd dimesnion item.
Using the
bool operator== (const container& c1, const container& c2);, it is described as:
Code:
Performing a comparison one vector to another takes linear time.
Two `containers` are equal if:
1. Their size is the same, and
2. Each member in location i in one vector is equal to the
member in location i in the other vector.
Comparisons among vectors are done lexicographically.
As described in the
C++ reference
It will require a nested loop, but you could do a quick check uppon starting the outer loop, to make sure the item run through the inner loop will allways contain the least items, keeping that as fast as possible.