c++ - Iterating through an STL list -
this question has answer here:
- how iterate backwards through stl list? 5 answers
for computer science class, doing assignment on depth first search , need access adjacent vertices (which contained in list within struct). need use reverse iteration go through list teacher states in specifications:
"there several ways this, ,
for (it=x.end(); it!=x.begin(); it--)
not 1 of them."
any suggestions?
you use reverse iterator
for(auto it=x.rbegin(); != x.rend(); it++){...}
use crbegin()/crend()
if want const iterators.
Comments
Post a Comment