博文
STL算法学习(七)(2006-07-28 14:37:00)
摘要:/*find_end: 函数原型: template <class FdwIt1,class FdwIt2> FdwIt1 find_end(FdwIt1 first1,FdwIt1 last,FdwIt2 first2,FdwIt2 last2); template <class FdwIt1,class FdwIt2,class Pred> FdwIt1 find_end(FdwIt1 first1,FdwIt1 last,FdwIt2 first2,FdwIt2 last2, Pred pr); 功能:在由[first1,last1)标记的序列中查找“由iteratior对[first2,last2)标记 的第二个序列”的最后一次出现。例如,已知亭子符序列mississippi和第二 个序列ss,则find_end()返回一个FwdIt1指向第二个ss序列的第一个s。如果 &nbs......
STL算法学习(六)(2006-07-27 00:26:00)
摘要:/*fill: 函数原型: template <class FwdIt,class T> void fill(FwdIt first,FwdIt last,const T& value); 功能:将value拷贝到区间[first,last)中的每一个元素。
fill_n: 函数原型: template <class FwdIt,class Size,class T> void fill_n(FwdIt first,Size n,const T& value); 功能:将value拷贝到从first开始的n个元素上。 find: 函数原型: template <class InputIterator,class T> InputIterator find(InputIterator first,InputIterator last,const T&......
STL算法学习(五)(2006-07-24 17:37:00)
摘要:/*equal: 函数原型: template <class InputIterator1,class InputIterator2> bool equal(InputIterator1 first1,InputIterator1 last1,InputIterator2 first2); template <class InputIterator1,class InputIterator2 class Predicate> bool equal(InputIterator1 first1,InputIterator1 last1,InputIterator2 first2, Predicate pred); 功能: 第一个版本将序列[first1,la......
STL算法学习(四)(2006-07-22 16:51:00)
摘要:/*count: 函数原型: template <class InputIterator,class Type> typename iterator_traits<InputIterator>::difference_type count(InputIterator first,InpurIterator last,const Type& value); 功能: 在序列[first,last)中查找和value相等的元素个数,统计其个数,返回其值。
count_if: 函数原型: template <class InputIterator,class Predicate> typename iterator_traits<InputIterator>::difference_type count_if(InputIterator first,InputIterator last,Predicate pred); 功能: 在序列[first,last)中统计满足关系pred的元素个数,并返回其值。......
STL算法学习(三)(2006-07-21 10:42:00)
摘要:/*copy 函数原型: template <class InputIterator,class OutputIterator> OutputIterator copy(InputIterator first1,InputIterator last1,OuputIteratoo first2); 功能:将序列[first1,last1)内的元素从由first2指定的开始位置依次进行拷贝。函数 返回拷贝后指向最后一个元素的下一个位置的迭代器。 copy_backward 函数原型: template <class BidirectionalIterator1,class BidirectionalIterator2> BidirectionalIterator2 copy_backward(BidirectionalIterator1 first1,BidirectionalIterator1 last1, &nb......
STL算法学习(二)(2006-07-20 12:27:00)
摘要:/*adjacent_find 函数原型: template <class ForwardIterator> ForwardIterator adjacent_find(ForwardIterator first,ForwardIterator last); template <class ForwardIterator,class BinaryOperation> ForwardIterator adjacent_find(ForwardIterator first,ForwardIterator last BinaryOperation op); 功能:第一个版本,在序列[first,last)中查找相邻元素之间第一对相 等的元素,并返回这样一个前向迭代器,若找到它指向相等元素 对的第一个元素,没找到,则返回last。第二个版本相邻元素之 间的关系由用户指定。
binary_search 函数原型: template <class F......
STL算法学习(一)(2006-07-19 10:51:00)
摘要:/*accumulate(): * 函数原型:template <class InputIterator,class Type> * Type accumulate(InputIterator first,InputIterator last,Type init); * template <class InputIterator,class Type,class BinaryOperation> * Type accumulate(InputIterator first,InputIterator last,Type init,BinaryOperation op) * * 功能:函数的第一个版本将Iterator[fisrt,last)范围内对象和init累加起来,函数返回计算 的 * 结果值。例如,序列(1,5,6,9,8,5,3),init为2,应用该函数后结果是39。第二个版本, * 用对象的操作 不再是加法了,具体操作由用户指定。由于这个函数是算术操作, 因此我们在使用它的时 候,必须包含头文件<numeric> 。 * *......
