Answers for "iterate vector from end to begin"

C++
1

iterate vector from end to begin

for ( vector<int>::reverse_iterator i = my_vector.rbegin(); 
        i != my_vector.rend(); ++i ) { 
}

OR

vector<my_class>::iterator i = my_vector.end();
while (i != my_vector.begin())
{
     --i;
    /*do stuff */

}
Posted by: Guest on September-30-2021

Browse Popular Code Answers by Language