Iterating over a vector in reverse direction

前端 未结 9 547
面向向阳花
面向向阳花 2020-12-08 04:36

I need to iterate over a vector from the end to the beginnig. The \"correct\" way is

for(std::vector::reverse_iterator rit = v.rbegin(); rit !=          


        
9条回答
  •  时光说笑
    2020-12-08 04:56

    Hi i think better way use iterator as you use in first sample and if you need get iterator index you can use std::distance to calculate it, if i understand your question

提交回复
热议问题