算法库algorithm-8-cxx14
来源:互联网 发布:知乎2017校园招聘 编辑:程序博客网 时间:2024/06/04 19:14
概述
#include <boost/algorithm/cxx14/equal.hpp>//equal#include <boost/algorithm/cxx14/is_permutation.hpp>//is_permutation#include <boost/algorithm/cxx14/mismatch.hpp>//mismatch
测试
#include <laok.h>#include <boost/algorithm/cxx14/equal.hpp>//equal#include <boost/algorithm/cxx14/is_permutation.hpp>//is_permutation#include <boost/algorithm/cxx14/mismatch.hpp>//mismatch#include <boost/array.hpp>JOB_DEFINE(boost_algorithm , equal){boost::array<int,3> seq1 = { 0, 1, 2 };boost::array<int,5> seq2 = { 0, 1, 2, 3, 4 };using namespace boost::algorithm;PS( std::equal ( seq1.begin (), seq1.end (), seq2.begin ()) ); // truePS( std::equal ( seq2.begin (), seq2.end (), seq1.begin ()) ); // Undefined behaviorPS( equal ( seq1.begin (), seq1.end (), seq2.begin (), seq2.end ()) ); // false}JOB_DEFINE(boost_algorithm , mismatch){using namespace boost::algorithm;boost::array<int,6> c1 = { 0, 1, 2, 3, 14, 15 };boost::array<int,3> c2 = { 1, 2, 3 };std::pair<int* , int*> ret = mismatch ( c1.begin(), c1.end(), c2.begin(), c2.end()) ;std::cout << "arr1 point:" << std::distance(c1.begin() , ret.first) << " arr2 point:" << std::distance(c2.begin() , ret.second) << std::endl;// --> <c1.begin(), c2.begin()> // first elements do not matchret = mismatch ( c1.begin() + 1, c1.begin() + 4, c2.begin(), c2.end());std::cout << "arr1 point:" << std::distance(c1.begin() , ret.first) << " arr2 point:" << std::distance(c2.begin() , ret.second) << std::endl;// --> <c1.begin() + 4, c2.end ()> // all elements of `c2` matchret = mismatch ( c1.end(), c1.end(), c2.end(), c2.end());std::cout << "arr1 point:" << std::distance(c1.begin() , ret.first) << " arr2 point:" << std::distance(c2.begin() , ret.second) << std::endl;// --> <c1.end(), c2.end()> // empty sequences don't match at the end.}
运行
=====<boost_algorithm_equal>begin[std::equal ( seq1.begin (), seq1.end (), seq2.begin ())]:[true][std::equal ( seq2.begin (), seq2.end (), seq1.begin ())]:[false][equal ( seq1.begin (), seq1.end (), seq2.begin (), seq2.end ())]:[false]=====<boost_algorithm_equal>end [State:OK] [Times:0.008s]=====<boost_algorithm_mismatch>beginarr1 point:0 arr2 point:0arr1 point:4 arr2 point:3arr1 point:6 arr2 point:3=====<boost_algorithm_mismatch>end [State:OK] [Times:0.023s]
0 0
- 算法库algorithm-8-cxx14
- 算法库algorithm-1-algorithm
- C++ 算法库algorithm
- STL algorithm算法copy_if(8)
- boost::algorithm(字符串算法库)
- 算法库algorithm-0-概览
- 算法库algorithm-2-clamp
- 算法库algorithm-3-gather
- 算法库algorithm-4-hex
- 算法库algorithm-5-minmax
- 算法库algorithm-6-searching
- 算法库algorithm-7-cxx11
- 算法库algorithm-9-string
- Algorithm(算法
- 算法(algorithm):
- Algorithm算法
- Dijkstra Algorithm 算法详解
- Algorithm: 算法题摘录
- HTML5&CSS3笔记:流式布局
- SSH框架百度文库地址
- GDI+如何判断一个点是否在区域内
- secureCRT端口转发功能突破防火墙限制
- 【Android自定义View实战】之你应该明白的事儿
- 算法库algorithm-8-cxx14
- jq异步绑定事件方法返回值:jQuery delegate(selector,[type],[data],fn)
- c++的继承
- 欢迎使用CSDN-markdown编辑器
- React Native 学习笔记二十一(定时器学习)
- JMS简介(一)
- 算法库algorithm-9-string
- CUDA 学习(三)、CUDA硬件概述
- 常见的用户密码加密方式以及破解方法