C++:distance()
来源:互联网 发布:大作家智能写作软件 编辑:程序博客网 时间:2024/05/21 15:01
function template
std::distance
template
typename iterator_traits::difference_type
distance (InputIterator first, InputIterator last);
Return distance between iterators
Calculates the number of elements between first and last.
If it is a random-access iterator, the function uses operator- to calculate this. Otherwise, the function uses the increase operator (operator++) repeatedly.
Parameters
first: Iterator pointing to the initial element.
last: Iterator pointing to the final element. This must be reachable from first.
InputIterator shall be at least an input iterator.
Return value
The number of elements between first and last.
Example
// advance example
#include <iostream> // std::cout#include <iterator> // std::distance#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 first = mylist.begin(); std::list<int>::iterator last = mylist.end(); std::cout << "The distance is: " << std::distance(first,last) << '\n'; return 0;}
Output:
The distance is: 10
- C++:distance()
- 【word2vec】distance.c源码
- [leetcode-72]Edit Distance(C)
- 461. Hamming Distance(C++)
- 477. Total Hamming Distance(C++)
- Distance
- distance
- distance
- Distance
- 【DP】 Shortest Edit Distance in C
- Codeforces C - Bear and String Distance (贪心)
- codeforces 628C Bear and String Distance
- CodeForces 628C - Bear and String Distance
- coeforces 628C. Bear and String Distance
- CodeForces 628C Bear and String Distance
- C:曼哈顿距离(manhattan distance)问题
- 461. Hamming Distance(c语言)
- leetcode 461. Hamming Distance(C语言)
- Python十进制数学计算模块decimal
- Java框架篇---Mybatis 入门
- 扔鸡蛋问题
- Context-aware Natural Language Generation with Recurrent Neural Networks
- Hadoop修改权限问题
- C++:distance()
- 清理日志及文件内容的三种方法
- PAT甲级1017. Queueing at Bank (25)
- MongoDB基础学习二----MongoDB中常用的索引操作
- Learning Deep Structured Semantic Models for Web Search using Clickthrough Data笔记
- NTP时钟同步服务器安装
- SwipeRefreshLayout无法下拉刷新了
- 蓝桥杯-四阶幻方
- POJ1988:Cube Stacking(并查集)