I have an unordered set in which i want to apply nested loops. The second loop’s iterator should begin from next pointer of first loop’s iterator. Can someone please suggest how to achieve this in cpp?
1 Like
You can do like:
for(iterator1=set.begin();iterator1!=set.end();iterator1++)
{
i=iterator1; //i is one more iterator
iterator1++;
i2=iterator1;
iterator1=i;
for(iterator3=i2;iterator3!=set.end();iterator3++)
{
//your code here.
//Note that you can't write iterator3=iterator1 + 1 as it will give error .
}
}
1 Like
Thanks