Hi
I am trying to find the most efficient, optimized and fastest way to compare to std vectors of CString. the strings in question are case-sensitive. I have tried using the == operator for the vector container but this sometimes return false positives. I mean for instance if one vector contains elements in the order (a,b,c) and the other has them in the order (b,c,a) the == operator will return false even thought they share the same data. Another thing is that it does not do case sensitive comparison.
I have thought of using a basic nested loops approach like this:
//Not Tested
BOOL bMatch = TRUE;
for(int i=0; i<Vec1.size();i++)
{
if(!bMatch)
break;
int nComp=0;
for(int j=0;j<Vec2.size();j++)
{
if(vec1[i].CompareNoCase(Vec2[j])==0)
{
//We have a match--check next item
break;
}
else
{
nComp++;
if(nComp == Vec2.size()-1)
{
//Reached end of vector and no match found
//Vectors don't match
bMatch=FALSE;
}
}
}
}
The above code is not tested and I am not sure if there is probably a better way to achieve such comparison without the need of using nested loops.
Would appreciate any advice or help...