I have a list<pair<int , double>> lSeedList
and an unordered_set<int> sToDelete
. I want to remove the pairs in the list that have their first member equal to an int in sToDelete. Currently I am using the following code :
void updateSL(list<pair<int, double> >& lSeedList, const unordered_set<int>& sAddedFacets)
{
list<pair<int, double> >::iterator it = lSeedList.begin();
while(it != lSeedList.end())
{
if(sAddedFacets.count(it->first) != 0)
it = lSeedList.erase(it);
else
++it;
}
}
Is there a way to speed up this code ? Is it possible to efficiently parallelize it with OpenMP (dividing the list in each thread and then merging them with splice) ?
I am using Visual Studio 2010 under Windows 7. The size of lSeedList is ~1 million at the start and the size of sToDelete is ~10000. The int in the pair acts like an unique ID.