zoukankan      html  css  js  c++  java
  • STL: 测试序列中元素

    all_of

    Returns true when a condition is present at each element in the given range.

    template<class InputIterator, class Predicate>
        bool all_of(
            InputIterator _First, 
            InputIterator _Last, 
            BinaryPredicate _Comp
        );

    any_of

    Returns true when a condition is present at least once in the specified range of elements.

     
    template<class InputIterator, class UnaryPredicate>
        bool any_of(
            InputIterator _First, 
            InputIterator _Last, 
            UnaryPredicate _Comp
        );

    none_of

    Returns true when a condition is never present among elements in the given range.

    template<class InputIterator, class BinaryPredicate> 
        bool none_of( 
            InputIterator _First, 
            InputIterator _Last, 
            BinaryPredicate _Comp 
        );

    is_heap

    Returns true if the elements in the specified range form a heap.

    template<class RandomAccessIterator>
        bool is_heap(
            RandomAccessIterator _First,
            RandomAccessIterator _Last
        );
    template<class RandomAccessIterator, class BinaryPredicate>
        bool is_heap(
            RandomAccessIterator _First,
            RandomAccessIterator _Last,
            BinaryPredicate _Comp
        );

    注,The first template function returns is_heap_until(_First,_Last) ==_Last.

    The second template function returns  is_heap_until(_First,_Last,_Comp) ==_Last.

    is_heap_until

    Returns a RandomAccessIterator that is set to the last element that forms a heap.(VS2012文档这里好像有问题,文档显示返回bool,但是编译器提示为一个迭代器)

    template<class RandomAccessIterator>
        RandomAccessIterator is_heap_until(
            RandomAccessIterator _First, 
            RandomAccessIterator _Last
    );
    template<class RandomAccessIterator, class BinaryPredicate> 
        RandomAccessIterator is_heap_until(
            RandomAccessIterator _First, 
            RandomAccessIterator _Last, 
            BinaryPredicate _Comp
    );

    is_partitioned

    Returns true if all the elements in the given range that test true for a condition come before any elements that test false.

     
    template<class InputIterator, class BinaryPredicate>
        bool is_partitioned(
            InputIterator _First, 
            InputIterator _Last,
            BinaryPredicate _Comp
        );

    is_sorted

    Returns true if the elements in the specified range are in sorted order.

    template<class ForwardIterator>
        bool is_sorted(
            ForwardIterator _First, 
            ForwardIterator _Last
        );
    template<class ForwardIterator, class BinaryPredicate>
        bool is_sorted(
            ForwardIterator _First, 
            ForwardIterator _Last, 
            BinaryPredicate _Comp
        );

    注,

    The first template function returns is_sorted_until(_First,_Last) ==_Last. The operator< function performs the order comparison.

    The second template function returns is_sorted_until(_First,_Last,_Comp) ==_Last. The _Comp predicate function performs the order comparison.

    is_sorted_until

    Returns a ForwardIterator that is set to the last element that is in sorted order from a specified range.

    The second version lets you provide a BinaryPredicate function that returns true when two given elements are in sorted order, and false otherwise.

    template<class ForwardIterator>
        ForwardIterator is_sorted_until(
            ForwardIterator _First, 
            ForwardIterator _Last
        );
    template<class ForwardIterator, class BinaryPredicate>
        ForwardIterator is_sorted_until(
            ForwardIterator _First, 
            ForwardIterator _Last, 
            BinaryPredicate _Comp
        );
  • 相关阅读:
    LAMP 服务器环境
    LAMP 环境搭建
    为何程序员总喜欢写技术博客,看完恍然大悟...
    沉入海底2年的微软数据中心浮出水面:故障率只有陆地上的1/8,除了长点贝类和藻类完全没问题...
    真正毁掉一个人的,是“打工者心态”
    包装严重的 IT 行业,作为面试官,我是如何甄别应聘者的包装程度
    一名测试实习生的心路历程(二)
    7年赚的2个亿,数学家6年就花光了,全砸在自家的房子上
    “蚂蚁牙黑,蚂蚁呀吼”一夜间火遍全网?别忽略了潜在风险
    面试常问的 25+ 个 Linux 命令
  • 原文地址:https://www.cnblogs.com/freewater/p/2954321.html
Copyright © 2011-2022 走看看