I have different type of string and I need to find out the duplicate entry in this string. Different type of string
string aStr= "1.1,1.2,1.3, 1"; //output should be duplicate entry
string aStr= "1.1,1.2,1.3"; //Ouput NO duplicate entry
string aStr= "1,2,1"; //o/p duplicate entry
string aStr = "1,2,3";//output No duplicate
I have tried as
std::vector < std::string > aOutString;
std::set <int> full_list;
std::set <std::string> aEntryInDouble;
int aNum1;
boost::split(aOutString, aStr , boost::is_any_of(","));
for(size_t it = 0; it < aOutString.size(); ++it)
{
if (aOutString[it].find('.') != std::string::npos)
{
//If entry is like "1.1,1.2,1.3"
if( !aEntryInDouble.insert(aOutString[it]).second )
{
aDup = false;
break;
}
}
else
{
//For entry "1,2,1"
aNum1 = std::atoi(aOutString[it].c_str());
if(aNum1)
{
if( !full_list.insert(aNum1).second )
{
aDup = false;
break;
}
}
- I am not able to find out the solution for entry string "string aStr= "1.1,1.2,1.3, 1"; Please help me to find out the solution.
Thanks,