首页 > 编程知识 正文

迭代器有什么用,c++迭代器

时间:2023-05-06 20:28:56 阅读:49235 作者:3870

文章目录1 .使用案例

1 .使用案例# includeqcoreapplication # includeqmapiterator # includeqmutablemapiterator # includeqdebugintmain (qmapqstring,qtttring ) map.insert(Paris,) France ); map.insert(guatemalacity,) Guatemala ); map.insert(mexicocity,) Mexico ); map.insert(Moscow,) Russia ); QMapIteratorQString,qstringi (映射; while(I.hasnext () ) { i.next ); q调试(I.key ) ) ' : ) I.value ); }if(I.findprevious('Mexico ) ) qDebug ) ) ) find 'Mexico ) ); //正向搜索关键字的值QMutableMapIteratorQString,qstringj(map; while(j.hasnext () if (j.next ).key ) (.//endsWith ) )是QString类的函数j.remove ) ); //(删除包含以“city”结尾的键的项目(while ) j.hasprevious ) ) { j.previous ); //当前键值对为((paris,France ),(Moscow,Russia ) qDebug ) (j.key ) )、 ) j.value ); } return a.exec (; }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。