摘要: 寻找相等的相邻元素adjacent_find(first, last){ if(first == last) return last; ForwardIterator next = first; while(++next != last) { if(*next == *first) return first; first = next; } return last;}统计与value元素相等的元素的个数template <class InputIterator, class T>typename... 阅读全文
posted @ 2012-04-27 11:31 w0w0 阅读(205) 评论(0) 推荐(0) 编辑
摘要: STL中定义的set要求元素不得重复且已经排序set算法要求的都是有序区间,但元素可以重复出现另外提供的hash版本的set因为其元素无序,因此不能作为set函数的参数set算法前4个参数分别表示两个区间,第五个参数表示存放结果的区间的起始位置。还允许用户指定a<b的意义,判断两个元素是否相等全靠小于运算先给个例子#include<set>#include<iostream>#include<algorithm>#include<iterator>using namespace std;template <class T>str 阅读全文
posted @ 2012-04-27 09:32 w0w0 阅读(382) 评论(0) 推荐(0) 编辑