这看起来是否正确? [英] Does this look correct?
问题描述
我想向后查看std :: list ....
std :: list< mytype> :: reverse_iterator it;
for(it = out.rbegin(); it!= out.rend(); - ))
{
...
}
I want to go through a std::list backwards....
std::list<mytype>::reverse_iterator it;
for (it=out.rbegin(); it != out.rend(); --it)
{
...
}
推荐答案
JustSomeGuy写道:
JustSomeGuy wrote:
我想通过一个标准: :向后列出....
std :: list< mytype> :: reverse_iterator it;
for(it = out.rbegin(); it!= out。 rend(); - ))
{
...
}
I want to go through a std::list backwards....
std::list<mytype>::reverse_iterator it;
for (it=out.rbegin(); it != out.rend(); --it)
{
...
}
看起来正确。唯一的事情是,如果你修改
迭代中的列表,那么迭代器_may_就会变得无效。如果
你的'''''包含类似
out.erase(it);
$ b $那么这是一个错误,因为''它'在那之后是无效的。另外,那里有
似乎没有必要在''for'之外声明''它''。保持紧张:
for(std :: list< mytype> :: reverse_iterator it = out.rbegin(); ...
V
-
请在邮寄回复时从我的地址删除资金
Looks correct. The only thing is that if you modify the list in the
middle of iterating through it, the iterator _may_ become invalid. If
your ''...'' contain something like
out.erase(it);
then it''s a mistake because ''it'' is invalid after that. Also, there
seems to be no need to declare ''it'' outside of the ''for''. Keep it tight:
for (std::list<mytype>::reverse_iterator it = out.rbegin(); ...
V
--
Please remove capital As from my address when replying by mail
所以 - 它是正确的...它不是++它(在for循环控制中)
So the --it is correct... It isn''t ++it (In the for loop control)
JustSomeGuy写道:
JustSomeGuy wrote:
所以-it是正确的...它不是++它(在for循环控件中)
So the --it is correct... It isn''t ++it (In the for loop control)
许多迭代器都可以实现作为指针,所以...
-
Phlip
http://www.greencheese.org/ZeekLand < - 不是博客!!!
Many iterators can implement as pointers, so...
--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
这篇关于这看起来是否正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!