I work with data that should not appear twice. If so, it should detect it and invoke the processing of the function.
I am currently pushing some data towards the vector and before inserting it, it must check whether the data is already contained in this vector. At the moment it is not very effective, for example
for (int i = 0; i < myVector.size() ; i++)
{
if ( myVector[i] == data )
{
return false;
}
}
I know that set- this is a special kind of vector that allows you to use only unique data.
Is there any other way to detect duplicate data being added (or at least trying to add it) in set?
source
share