• 最大值最小值(max,max_element)


    min

      如果比不出大小就返回第一个引数

    //版本一:调用operator< 
    template <class LessThanComparable>
    const LessThanComparable& min(const LessThanComparable &a,const LessThanComparable& b);
    
    //版本二:调用自己定义的function object来比较
    template <class T,class BinaryPredicate>
    const T& min(const T &a,const T& b,v cmp);

    max

      如果比不出大小就返回第一个引数

    //版本一:调用operator< 
    template <class LessThanComparable>
    const LessThanComparable& max(const LessThanComparable &a,const LessThanComparable& b);
    
    //版本二:调用自己定义的function object来比较
    template <class T,class BinaryPredicate>
    const T& max(const T &a,const T& b,v cmp);

    min_element

      返回range内再有没有其他iterator 指向的值小于*i的iterator i,如果range为空,返回last

    //版本一:调用operator< 
    template <class ForwardIterator>
    ForwardIterator min_element(ForwardIterator first,ForwardIterator last);
    
    //版本二:调用自己定义的function object来比较,返回cmp(*j,*i)为false的i
    template <class ForwardIterator,class BinaryPredicate>
    ForwardIterator min_element(ForwardIterator first,ForwardIterator last,BinaryPredicate cmp);

    max_element

      返回range内再也没有其他iterator所指的值大于*i的iterator i,若为空,返回last

    //版本一:调用operator< 
    template <class ForwardIterator>
    ForwardIterator max_element(ForwardIterator first,ForwardIterator last);
    
    //版本二:调用自己定义的function object来比较,返回cmp(*i,*j)为false的i
    template <class ForwardIterator,class BinaryPredicate>
    ForwardIterator max_element(ForwardIterator first,ForwardIterator last,BinaryPredicate cmp);
  • 相关阅读:
    python3 进程_multiprocessing模块
    python3 线程_threading模块
    python3 异常处理
    python3 面向对象补充
    python3 多态,绑定方法与非绑定方法
    python3 uper(),继承实现原理,封装
    python3 面向对象、类、继承、组合、派生、接口、子类重用父类方法
    python3 正则表达式re模块
    python3 json、logging、sys模块
    mysql查询练习
  • 原文地址:https://www.cnblogs.com/tianzeng/p/10403569.html
Copyright © 2020-2023  润新知