Faster way to compare all vector elements

This sample code takes longer time for larger array size
what are the other alternative function i can use to compare if all vector contents are equal.


1
2
3
4
5
6
7
8
9
10
std::vector<BYTE> vecID;

bool bEqual = true;
for ( int n1=0; n1<vecID.size(); ++n1 )
{
	for ( int n2=0; n2<vecID.size(); ++n2 )
	{
		if( vecID[n1] != vecID[n2] )	bEqual = false;
	}
}
1
2
3
4
5
6
7
8
9
std::vector<BYTE> vecID;

bool bEqual = true;
for ( int n1=1; n1<vecID.size(); ++n1 )
{
		if( vecID[n1-1] != vecID[n1] ) {	bEqual = false;
				break;
	}
}
thanks a lot
Topic archived. No new replies allowed.