存储在STL列表中的项目顺序不会保留。 [英] The order of items stored in STL List is not preserved.

查看:55
本文介绍了存储在STL列表中的项目顺序不会保留。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




怎么会发生这种情况?我没有插入或删除

列表中的任何项目,但是当我从列表中打印出来时,项目的顺序是由STL列表随机重新排列的




Sam。

Hi,

How could this happened? I did not insert or delete any items in the
list, but when I print it out from the list, the order of the items are
randomly rearranged by STL list.

Sam.

推荐答案



" sam" < SAM ++ @ - COM>。在留言新闻中写道:d5 *********** @ news.hgc.com.hk ...

"sam" <sam++@--.com> wrote in message news:d5***********@news.hgc.com.hk...


怎么会发生这种情况?我没有插入或删除列表中的任何项目,
但是当我从列表中打印出来时,项目的顺序是由STL列表随机重新排列的。

Sam。
Hi,

How could this happened? I did not insert or delete any items in the list,
but when I print it out from the list, the order of the items are randomly
rearranged by STL list.

Sam.




嗯,我认为你必须在某个时候插入,否则它会是空的!

: - )


无论如何,std :: list永远不会随机播放其内容,因此在插入或遍历时,代码中的代码必须有错误。发布您使用的代码

填写并报告其内容,也许我们可以发现

错误。


-Howard



Well, I assume you must have inserted at some point, or it would be empty!
:-)

Anyway, std::list never shuffles its contents, so there must be an error in
your code, either when inserting or when traversing. Post the code you used
for filling it and for reporting its contents, and maybe we can spot the
error.

-Howard


sam写道:
怎么会发生这种情况?我没有插入或删除
列表中的任何项目,但是当我从列表中打印出来时,项目的顺序是由STL列表随机重新排列。
How could this happened? I did not insert or delete any items in the
list, but when I print it out from the list, the order of the items are
randomly rearranged by STL list.




这包含在FAQ 5.8中。


V



This is covered in the FAQ 5.8.

V


你好Victor,
感谢您是否可以转发该常见问题解答的直接链接。


谢谢

Ganesh


Victor Bazarov写道:
Hi Victor,
Appreciate if you could forward the direct link for that FAQ.

Thanks
Ganesh

Victor Bazarov wrote:
sam写道:
这怎么可能发生?我没有插入或删除列表中
中的任何项目,但是当我从列表中打印出来时,项目
的顺序会被STL列表随机重新排列。
How could this happened? I did not insert or delete any items in the list, but when I print it out from the list, the order of the items are randomly rearranged by STL list.



这包含在FAQ 5.8中。

V



This is covered in the FAQ 5.8.

V






这篇关于存储在STL列表中的项目顺序不会保留。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆