C++ std::advance给迭代器增加指定偏移量
来源:互联网 发布:淘宝虚拟充值软件 编辑:程序博客网 时间:2024/05/29 14:21
template <class InputIterator, class Distance> void advance (InputIterator& it, Distance n);
迭代器辅助函数。
使迭代器it偏移n,其中n为整数。
#include <iostream> // std::cout#include <iterator> // std::advance#include <list> // std::listint main () { std::list<int> mylist; for (int i=0; i<10; i++) mylist.push_back (i*10); std::list<int>::iterator it = mylist.begin(); std::advance (it,5); std::cout << "The sixth element in mylist is: " << *it << '\n'; std::advance (it,-1); std::cout << "The fifth element in mylist is: " << *it << '\n'; return 0;}
The sixth element in mylist is: 50The fifth element in mylist is: 40
参考:
https://www.cnblogs.com/lc-cnblong/archive/2013/07/17/3196199.html
阅读全文
0 0
- std::advance 给迭代器增加指定偏移量
- C++ std::advance给迭代器增加指定偏移量
- C指针偏移量
- std::map 迭代器偏移出错
- c++ std:: advance
- C语言中的指针加减偏移量
- C/C++内存偏移量学习笔记
- C语言中的指针加减偏移量
- C语言中的指针加减偏移量
- C语言中的指针加减偏移量
- C++:获取类成员的偏移量
- C语言偏移任意指针量
- C++:获取类成员的偏移量
- C语言中内存偏移量
- oracle中对日期时间变量增加偏移量
- 偏移量
- 偏移量
- std::advance std::distance std::next
- bzoj1457: 棋盘游戏
- [3]深度学习和Keras----Keras深度学习框架入门例子
- pat 甲级 1003 Emergency
- Banana Pi M2U系列之一:前言
- C++/MFC-IP Address Control
- C++ std::advance给迭代器增加指定偏移量
- 什么是类加载器
- Idea项目如何迁移到Eclipse
- 如何使用 Android O 的自动填充框架
- android开源代码编译方法
- xgboost入门与实战(实战调参篇) 标签: xgboostpythonkaggle机器学习
- React.js笔记
- hibernate学习笔记03----一级缓存
- java 方法的重载和覆盖