ITPub博客

首页 > 应用开发 > Java > STL iterator delete problem

STL iterator delete problem

原创 Java 作者:wangzh3 时间:2008-02-19 22:10:36 0 删除 编辑

years ago carl report problem in chinaunix.net: bug of stl on hpux.when delete some element in the stl containers,not work.others ok.

now i encount the problem again,but not bug.and the solution:

for(iterator continue)

{

if(want to delete)

{

delete the pointer;

delete the element and move on the cursor;

}

else

{

increment

}

}

and use the r iterator also will be ok.just because when you delete the elemetn.so the iteraotr changed,then error occurs

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/47869/viewspace-999701/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: java map
请登录后发表评论 登录
全部评论
  • 博文量
    301
  • 访问量
    10875968