It produces the information about duplicates in the vector.
int FindDuplicates( vector<int> & vnMapIndices, vector<uint> & vnR1s, BOOL bCaseSensitive = false, vector<uint>& vnOccurences = NULL, DWORD dwCntrl = 0 )
the size of vnR1s if success, otherwise a negative number.
EX1
/* If the source vector is: {4, 2, 1, 3, 1, 2, 1} then: vnMapIndices = {-1, 1, 0, -1, 0, 1, 0} vnR1s = {2, 1} vnOccurences = {3, 2} */ void vector_FindDuplicates_ex1() { vector<string> strVec = {"4","2","1","3","1","2","1"}; vector<int> vnMapIndices; vector<uint> vnR1s; BOOL bCaseSensitive = false; vector<uint> vnOccurences; int nRet = strVec.FindDuplicates(vnMapIndices, vnR1s, bCaseSensitive, vnOccurences); int ii; printf("Source"); for (ii = 0; ii < strVec.GetSize(); ++ii) { printf("%c %s", 0 == ii ? '=' : ',', strVec[ii]); } printf("\nnRet = %d\n", nRet); printf("vnMapIndices"); for (ii = 0; ii < vnMapIndices.GetSize(); ++ii) { printf("%c %d", 0 == ii ? '=' : ',', vnMapIndices[ii]); } printf("\nvnR1s "); for (ii = 0; ii < vnR1s.GetSize(); ++ii) { printf("%c %d", 0 == ii ? '=' : ',', vnR1s[ii]); } printf("\nvnOccurences "); for (ii = 0; ii < vnOccurences.GetSize(); ++ii) { printf("%c %d", 0 == ii ? '=' : ',', vnOccurences[ii]); } }
This method only worked for string type vector. For numeric type vector, need to convert to string type firstly, like convert_double_vector_to_string_vector.
origin.h