Iterating over a vector in reverse direction

前端 未结 9 573
面向向阳花
面向向阳花 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 05:05

    loop condition i != std::numeric_limits::max() ... or use UINT_MAX if you think its to verbose. or another way:
    for(unsigned j=0, end=v.size(), i=end-1; j
    or
    for(unsigned end=v.size(), i=end-1; (end-i)

提交回复
热议问题