迭代器 GIS

迭代器是内部做好的模板

可以用在迭代器的操作有  *, ++, ==, !=,

list<char> testchar;

list<char>::iterator pos;

for(pos=testchar.begin();pos!=testchar。end();++pos) // 一般用++pos ,不是pos++ ,这样更快

{

cout<< *pos; // *pos 代表当前元素
}

任何容器都有两种 iterator;

container::iterator  // 迭代器以读写方式访问元素

container::const_iterator // 只读方式访问

image

随机迭代器 支持< ,list ,set,maps 不支持随机迭代器,建议用!=

原文地址:https://www.cnblogs.com/gisbeginner/p/2839600.html