算法库algorithm-5-minmax

来源:互联网 发布:女超人于莺离婚知乎 编辑:程序博客网 时间:2024/06/05 00:20

概述

//最值对//tuple< T const&, T const& >minmax(T const& a, T const& b)//tuple< T const&, T const& >minmax(T const& a, T const& b, BinaryPredicate comp)//最值迭代器//std::pair<ForwardIter,ForwardIter>minmax_element(ForwardIter first, ForwardIter last)//std::pair<ForwardIter,ForwardIter>minmax_element(ForwardIter first, ForwardIter last, BinaryPredicate comp)//* first_min_element(first, last)//* first_min_element(first, last, comp)//* last_min_element(first, last)//* last_min_element(first, last, comp)//* first_max_element(first, last)//* first_max_element(first, last, comp)//* last_max_element(first, last)//* last_max_element(first, last, comp)//* first_min_first_max_element(first, last)//* first_min_first_max_element(first, last, comp)//* first_min_last_max_element(first, last)//* first_min_last_max_element(first, last, comp)//* last_min_first_max_element(first, last)//* last_min_first_max_element(first, last, comp)//* last_min_last_max_element(first, last)//* last_min_last_max_element(first, last, comp)


测试

#include <laok.h>#include <boost/algorithm/minmax.hpp>#include <boost/algorithm/minmax_element.hpp>JOB_DEFINE(boost_algorithm , minmax){int a = 10 , b = 100;boost::tuple<int,int> ret = boost::minmax(a,b);PS( ret.get<0>() );PS( ret.get<1>() );}


运行

=====<boost_algorithm_minmax>begin[ret.get<0>()]:[10][ret.get<1>()]:[100]=====<boost_algorithm_minmax>end [State:OK] [Times:0.003s]


扩展了std 的 min_element/max_element 




0 0
原创粉丝点击