当前头文件是算法库(Algorithm library)的部分内容。

算法库(参考手册) ​算法库(标准)

  • 不修改内容的序列操作:

    adjacent_find 查找两个相邻(Adjacent)的等价(Identical)元素
    all_of C++11 检测在给定范围中是否所有元素都满足给定的条件
    any_of C++11 检测在给定范围中是否存在元素满足给定条件
    count 返回值等价于给定值的元素的个数
    count_if 返回值满足给定条件的元素的个数
    equal 返回两个范围是否相等
    find 返回第一个值等价于给定值的元素
    find_end 查找范围 A 中与范围 B 等价的子范围最后出现的位置
    find_first_of  查找范围 A 中第一个与范围 B 中任一元素等价的元素的位置
    find_if 返回第一个值满足给定条件的元素
    find_if_not C++11 返回第一个值不满足给定条件的元素
    for_each 对范围中的每个元素调用指定函数
    mismatch 返回两个范围中第一个元素不等价的位置
    none_of C++11 检测在给定范围中是否不存在元素满足给定的条件
    search 在范围 A 中查找第一个与范围 B 等价的子范围的位置
    search_n 在给定范围中查找第一个连续 n 个元素都等价于给定值的子范围的位置

    修改内容的序列操作:

    copy 将一个范围中的元素拷贝到新的位置处
    copy_backward 将一个范围中的元素按逆序拷贝到新的位置处
    copy_if C++11 将一个范围中满足给定条件的元素拷贝到新的位置处
    copy_n C++11 拷贝 n 个元素到新的位置处
    fill 将一个范围的元素赋值为给定值
    fill_n 将某个位置开始的 n 个元素赋值为给定值
    generate 将一个函数的执行结果保存到指定范围的元素中,用于批量赋值范围中的元素
    generate_n 将一个函数的执行结果保存到指定位置开始的 n 个元素中
    iter_swap 交换两个迭代器(Iterator)指向的元素
    move C++11 将一个范围中的元素移动到新的位置处
    move_backward C++11 将一个范围中的元素按逆序移动到新的位置处
    random_shuffle 随机打乱指定范围中的元素的位置
    remove 将一个范围中值等价于给定值的元素删除
    remove_if 将一个范围中值满足给定条件的元素删除
    remove_copy 拷贝一个范围的元素,将其中值等价于给定值的元素删除
    remove_copy_if 拷贝一个范围的元素,将其中值满足给定条件的元素删除
    replace 将一个范围中值等价于给定值的元素赋值为新的值
    replace_copy 拷贝一个范围的元素,将其中值等价于给定值的元素赋值为新的值
    replace_copy_if 拷贝一个范围的元素,将其中值满足给定条件的元素赋值为新的值
    replace_if 将一个范围中值满足给定条件的元素赋值为新的值
    reverse 反转排序指定范围中的元素
    reverse_copy 拷贝指定范围的反转排序结果
    rotate 循环移动指定范围中的元素
    rotate_copy 拷贝指定范围的循环移动结果
    shuffle C++11 用指定的随机数引擎随机打乱指定范围中的元素的位置
    swap 交换两个对象的值
    swap_ranges 交换两个范围的元素
    transform 对指定范围中的每个元素调用某个函数以改变元素的值
    unique 删除指定范围中的所有连续重复元素,仅仅留下每组等值元素中的第一个元素。
    unique_copy 拷贝指定范围的唯一化(参考上述的 unique)结果

    划分操作:

    is_partitioned C++11 检测某个范围是否按指定谓词(Predicate)划分过
    partition 将某个范围划分为两组
    partition_copy C++11 拷贝指定范围的划分结果
    partition_point C++11 返回被划分范围的划分点
    stable_partition 稳定划分,两组元素各维持相对顺序

    排序操作:

    is_sorted C++11 检测指定范围是否已排序
    is_sorted_until C++11 返回最大已排序子范围
    nth_element 部份排序指定范围中的元素,使得范围按给定位置处的元素划分
    partial_sort 部份排序
    partial_sort_copy 拷贝部分排序的结果
    sort 排序
    stable_sort 稳定排序

    二分法查找操作:

    binary_search 判断范围中是否存在值等价于给定值的元素
    equal_range 返回范围中值等于给定值的元素组成的子范围
    lower_bound 返回指向范围中第一个值大于或等于给定值的元素的迭代器
    upper_bound 返回指向范围中第一个值大于给定值的元素的迭代器

    集合操作:

    includes 判断一个集合是否是另一个集合的子集
    inplace_merge 就绪合并
    merge 合并
    set_difference 获得两个集合的差集
    set_intersection 获得两个集合的交集
    set_symmetric_difference 获得两个集合的对称差
    set_union 获得两个集合的并集

    堆操作:

    is_heap 检测给定范围是否满足堆结构
    is_heap_until C++11 检测给定范围中满足堆结构的最大子范围
    make_heap 用给定范围构造出一个堆
    pop_heap 从一个堆中删除最大的元素
    push_heap 向堆中增加一个元素
    sort_heap 将满足堆结构的范围排序

    最大/最小操作:

    is_permutation C++11 判断一个序列是否是另一个序列的一种排序
    lexicographical_compare 比较两个序列的字典序
    max 返回两个元素中值最大的元素
    max_element 返回给定范围中值最大的元素
    min 返回两个元素中值最小的元素
    min_element 返回给定范围中值最小的元素
    minmax C++11 返回两个元素中值最大及最小的元素
    minmax_element C++11 返回给定范围中值最大及最小的元素
    next_permutation 返回给定范围中的元素组成的下一个按字典序的排列
    prev_permutation 返回给定范围中的元素组成的上一个按字典序的排列
  • #include <initializer_list>
    namespace std
    {
        // non-modifying sequence operations:
        template <class InputIterator, class Predicate>
            bool all_of(InputIterator first, InputIterator last, Predicate pred);
        template <class InputIterator, class Predicate>
            bool any_of(InputIterator first, InputIterator last, Predicate pred);
        template <class InputIterator, class Predicate>
            bool none_of(InputIterator first, InputIterator last, Predicate pred);
     
        template<class InputIterator, class Function>
            Function for_each(InputIterator first, InputIterator last, Function f);
     
        template<class InputIterator, class T>
            InputIterator find(InputIterator first, InputIterator last,
                               const T& value);
        template<class InputIterator, class Predicate>
            InputIterator find_if(InputIterator first, InputIterator last,
                                  Predicate pred);
        template<class InputIterator, class Predicate>
            InputIterator find_if_not(InputIterator first, InputIterator last,
                                      Predicate pred);
     
        template<class ForwardIterator1, class ForwardIterator2>
            ForwardIterator1
            find_end(ForwardIterator1 first1, ForwardIterator1 last1,
                     ForwardIterator2 first2, ForwardIterator2 last2);
        template<class ForwardIterator1, class ForwardIterator2,
                 class BinaryPredicate>
            ForwardIterator1
            find_end(ForwardIterator1 first1, ForwardIterator1 last1,
                     ForwardIterator2 first2, ForwardIterator2 last2,
                     BinaryPredicate pred);
     
        template<class InputIterator, class ForwardIterator>
            InputIterator
            find_first_of(InputIterator first1, InputIterator last1,
                          ForwardIterator first2, ForwardIterator last2);
        template<class InputIterator, class ForwardIterator,
                 class BinaryPredicate>
            InputIterator
            find_first_of(InputIterator first1, InputIterator last1,
                          ForwardIterator first2, ForwardIterator last2,
                          BinaryPredicate pred);
     
        template<class ForwardIterator>
            ForwardIterator adjacent_find(ForwardIterator first,
                                          ForwardIterator last);
        template<class ForwardIterator, class BinaryPredicate>
            ForwardIterator adjacent_find(ForwardIterator first,
                                          ForwardIterator last,
                                          BinaryPredicate pred);
        template<class InputIterator, class T>
            typename iterator_traits<InputIterator>::difference_type
            count(InputIterator first, InputIterator last, const T& value);
        template<class InputIterator, class Predicate>
            typename iterator_traits<InputIterator>::difference_type
            count_if(InputIterator first, InputIterator last, Predicate pred);
     
        template<class InputIterator1, class InputIterator2>
            pair<InputIterator1, InputIterator2>
            mismatch(InputIterator1 first1, InputIterator1 last1,
                     InputIterator2 first2);
        template<class InputIterator1, class InputIterator2, class BinaryPredicate>
            pair<InputIterator1, InputIterator2>
            mismatch(InputIterator1 first1, InputIterator1 last1,
                     InputIterator2 first2, BinaryPredicate pred);
     
        template<class InputIterator1, class InputIterator2>
            bool equal(InputIterator1 first1, InputIterator1 last1,
                       InputIterator2 first2);
        template<class InputIterator1, class InputIterator2, class BinaryPredicate>
            bool equal(InputIterator1 first1, InputIterator1 last1,
                       InputIterator2 first2, BinaryPredicate pred);
     
        template<class ForwardIterator1, class ForwardIterator2>
            bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
                                ForwardIterator2 first2);
        template<class ForwardIterator1, class ForwardIterator2,
        class BinaryPredicate>
            bool is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
                                ForwardIterator2 first2, BinaryPredicate pred);
     
        template<class ForwardIterator1, class ForwardIterator2>
            ForwardIterator1 search(
                ForwardIterator1 first1, ForwardIterator1 last1,
                ForwardIterator2 first2, ForwardIterator2 last2);
        template<class ForwardIterator1, class ForwardIterator2,
                 class BinaryPredicate>
            ForwardIterator1 search(
                ForwardIterator1 first1, ForwardIterator1 last1,
                ForwardIterator2 first2, ForwardIterator2 last2,
                BinaryPredicate pred);
     
        template<class ForwardIterator, class Size, class T>
            ForwardIterator search_n(ForwardIterator first, ForwardIterator last,
                                     Size count, const T& value);
        template<class ForwardIterator, class Size, class T, class BinaryPredicate>
            ForwardIterator1 search_n(ForwardIterator first, ForwardIterator last,
                                      Size count, const T& value,
                                      BinaryPredicate pred);
     
        // modifying sequence operations:
     
        // copy:
        template<class InputIterator, class OutputIterator>
            OutputIterator copy(InputIterator first, InputIterator last,
                                OutputIterator result);
        template<class InputIterator, class Size, class OutputIterator>
            OutputIterator copy_n(InputIterator first, Size n,
                                  OutputIterator result);
        template<class InputIterator, class OutputIterator, class Predicate>
            OutputIterator copy_if(InputIterator first, InputIterator last,
                                   OutputIterator result, Predicate pred);
        template<class BidirectionalIterator1, class BidirectionalIterator2>
            BidirectionalIterator2 copy_backward(
                BidirectionalIterator1 first, BidirectionalIterator1 last,
                BidirectionalIterator2 result);
     
        // move:
        template<class InputIterator, class OutputIterator>
            OutputIterator move(InputIterator first, InputIterator last,
                                OutputIterator result);
        template<class BidirectionalIterator1, class BidirectionalIterator2>
            BidirectionalIterator2 move_backward(
                BidirectionalIterator1 first, BidirectionalIterator1 last,
                BidirectionalIterator2 result);
     
        // swap:
        template<class ForwardIterator1, class ForwardIterator2>
            ForwardIterator2 swap_ranges(ForwardIterator1 first1,
                                         ForwardIterator1 last1, ForwardIterator2 first2);
        template<class ForwardIterator1, class ForwardIterator2>
            void iter_swap(ForwardIterator1 a, ForwardIterator2 b);
        template<class InputIterator, class OutputIterator, class UnaryOperation>
            OutputIterator transform(InputIterator first, InputIterator last,
                                     OutputIterator result, UnaryOperation op);
     
        template<class InputIterator1, class InputIterator2, class OutputIterator,
                 class BinaryOperation>
            OutputIterator transform(InputIterator1 first1, InputIterator1 last1,
                                     InputIterator2 first2, OutputIterator result,
                                     BinaryOperation binary_op);
     
        template<class ForwardIterator, class T>
            void replace(ForwardIterator first, ForwardIterator last,
                         const T& old_value, const T& new_value);
        template<class ForwardIterator, class Predicate, class T>
            void replace_if(ForwardIterator first, ForwardIterator last,
                            Predicate pred, const T& new_value);
        template<class InputIterator, class OutputIterator, class T>
            OutputIterator replace_copy(InputIterator first, InputIterator last,
                                        OutputIterator result,
                                        const T& old_value, const T& new_value);
        template<class InputIterator, class OutputIterator, class Predicate, class T>
            OutputIterator replace_copy_if(InputIterator first, InputIterator last,
                                           OutputIterator result,
                                           Predicate pred, const T& new_value);
     
        template<class ForwardIterator, class T>
            void fill(ForwardIterator first, ForwardIterator last, const T& value);
        template<class OutputIterator, class Size, class T>
            OutputIterator fill_n(OutputIterator first, Size n, const T& value);
        template<class ForwardIterator, class Generator>
            void generate(ForwardIterator first, ForwardIterator last,
                          Generator gen);
        template<class OutputIterator, class Size, class Generator>
            OutputIterator generate_n(OutputIterator first, Size n, Generator gen);
     
        template<class ForwardIterator, class T>
            ForwardIterator remove(ForwardIterator first, ForwardIterator last,
                                   const T& value);
        template<class ForwardIterator, class Predicate>
            ForwardIterator remove_if(ForwardIterator first, ForwardIterator last,
                                      Predicate pred);
        template<class InputIterator, class OutputIterator, class T>
            OutputIterator remove_copy(InputIterator first, InputIterator last,
                                       OutputIterator result, const T& value);
        template<class InputIterator, class OutputIterator, class Predicate>
            OutputIterator remove_copy_if(InputIterator first, InputIterator last,
                                          OutputIterator result, Predicate pred);
     
        template<class ForwardIterator>
            ForwardIterator unique(ForwardIterator first, ForwardIterator last);
        template<class ForwardIterator, class BinaryPredicate>
            ForwardIterator unique(ForwardIterator first, ForwardIterator last,
                                   BinaryPredicate pred);
        template<class InputIterator, class OutputIterator>
            OutputIterator unique_copy(InputIterator first, InputIterator last,
                                       OutputIterator result);
        template<class InputIterator, class OutputIterator, class BinaryPredicate>
            OutputIterator unique_copy(InputIterator first, InputIterator last,
                                       OutputIterator result, BinaryPredicate pred);
     
        template<class BidirectionalIterator>
            void reverse(BidirectionalIterator first, BidirectionalIterator last);
        template<class BidirectionalIterator, class OutputIterator>
            OutputIterator reverse_copy(BidirectionalIterator first,
                                        BidirectionalIterator last,
                                        OutputIterator result);
     
        template<class ForwardIterator>
            ForwardIterator rotate(ForwardIterator first, ForwardIterator middle,
                                   ForwardIterator last);
        template<class ForwardIterator, class OutputIterator>
            OutputIterator rotate_copy(
                ForwardIterator first, ForwardIterator middle,
                ForwardIterator last, OutputIterator result);
     
        template<class RandomAccessIterator>
            void random_shuffle(RandomAccessIterator first,
                                RandomAccessIterator last);
        template<class RandomAccessIterator, class RandomNumberGenerator>
            void random_shuffle(RandomAccessIterator first,
                                RandomAccessIterator last,
                                RandomNumberGenerator&& rand);
        template<class RandomAccessIterator, class UniformRandomNumberGenerator>
            void shuffle(RandomAccessIterator first,
                         RandomAccessIterator last,
                         UniformRandomNumberGenerator&& rand);
     
        // partitions:
        template <class InputIterator, class Predicate>
            bool is_partitioned(InputIterator first, InputIterator last, Predicate pred);
     
        template<class ForwardIterator, class Predicate>
            ForwardIterator partition(ForwardIterator first,
                                      ForwardIterator last,
                                      Predicate pred);
     
        template<class BidirectionalIterator, class Predicate>
            BidirectionalIterator stable_partition(BidirectionalIterator first,
                                                   BidirectionalIterator last,
                                                   Predicate pred);
     
        template <class InputIterator, class OutputIterator1,
                  class OutputIterator2, class Predicate>
            pair<OutputIterator1, OutputIterator2>
            partition_copy(InputIterator first, InputIterator last,
                           OutputIterator1 out_true, OutputIterator2 out_false,
                           Predicate pred);
     
        template<class ForwardIterator, class Predicate>
            ForwardIterator partition_point(ForwardIterator first,
                                            ForwardIterator last,
                                            Predicate pred);
     
        // sorting and related operations:
     
        // sorting:
        template<class RandomAccessIterator>
            void sort(RandomAccessIterator first, RandomAccessIterator last);
        template<class RandomAccessIterator, class Compare>
            void sort(RandomAccessIterator first, RandomAccessIterator last,
                      Compare comp);
     
        template<class RandomAccessIterator>
            void stable_sort(RandomAccessIterator first, RandomAccessIterator last);
        template<class RandomAccessIterator, class Compare>
            void stable_sort(RandomAccessIterator first, RandomAccessIterator last,
                             Compare comp);
     
        template<class RandomAccessIterator>
            void partial_sort(RandomAccessIterator first,
                              RandomAccessIterator middle,
                              RandomAccessIterator last);
        template<class RandomAccessIterator, class Compare>
            void partial_sort(RandomAccessIterator first,
                              RandomAccessIterator middle,
                              RandomAccessIterator last, Compare comp);
        template<class InputIterator, class RandomAccessIterator>
            RandomAccessIterator partial_sort_copy(
                InputIterator first, InputIterator last,
                RandomAccessIterator result_first,
                RandomAccessIterator result_last);
        template<class InputIterator, class RandomAccessIterator, class Compare>
            RandomAccessIterator partial_sort_copy(
                InputIterator first, InputIterator last,
                RandomAccessIterator result_first,
                RandomAccessIterator result_last,
                Compare comp);
     
        template<class ForwardIterator>
            bool is_sorted(ForwardIterator first, ForwardIterator last);
        template<class ForwardIterator, class Compare>
            bool is_sorted(ForwardIterator first, ForwardIterator last,
                           Compare comp);
        template<class ForwardIterator>
            ForwardIterator is_sorted_until(ForwardIterator first, ForwardIterator last);
        template<class ForwardIterator, class Compare>
            ForwardIterator is_sorted_until(ForwardIterator first, ForwardIterator last,
                                            Compare comp);
     
        template<class RandomAccessIterator>
            void nth_element(RandomAccessIterator first, RandomAccessIterator nth,
                             RandomAccessIterator last);
        template<class RandomAccessIterator, class Compare>
            void nth_element(RandomAccessIterator first, RandomAccessIterator nth,
                             RandomAccessIterator last, Compare comp);
        // binary search:
        template<class ForwardIterator, class T>
            ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last,
                                        const T& value);
        template<class ForwardIterator, class T, class Compare>
            ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last,
                                        const T& value, Compare comp);
     
        template<class ForwardIterator, class T>
            ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last,
                                        const T& value);
        template<class ForwardIterator, class T, class Compare>
            ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last,
                                        const T& value, Compare comp);
     
        template<class ForwardIterator, class T>
            pair<ForwardIterator, ForwardIterator>
            equal_range(ForwardIterator first, ForwardIterator last,
                        const T& value);
        template<class ForwardIterator, class T, class Compare>
            pair<ForwardIterator, ForwardIterator>
            equal_range(ForwardIterator first, ForwardIterator last,
                        const T& value, Compare comp);
     
        template<class ForwardIterator, class T>
            bool binary_search(ForwardIterator first, ForwardIterator last,
                               const T& value);
        template<class ForwardIterator, class T, class Compare>
            bool binary_search(ForwardIterator first, ForwardIterator last,
                               const T& value, Compare comp);
     
        // merge:
        template<class InputIterator1, class InputIterator2, class OutputIterator>
            OutputIterator merge(InputIterator1 first1, InputIterator1 last1,
                                 InputIterator2 first2, InputIterator2 last2,
                                 OutputIterator result);
        template<class InputIterator1, class InputIterator2, class OutputIterator,
                class Compare>
            OutputIterator merge(InputIterator1 first1, InputIterator1 last1,
                                 InputIterator2 first2, InputIterator2 last2,
                                 OutputIterator result, Compare comp);
     
        template<class BidirectionalIterator>
            void inplace_merge(BidirectionalIterator first,
                               BidirectionalIterator middle,
                               BidirectionalIterator last);
        template<class BidirectionalIterator, class Compare>
            void inplace_merge(BidirectionalIterator first,
                               BidirectionalIterator middle,
                               BidirectionalIterator last, Compare comp);
     
        // set operations:
        template<class InputIterator1, class InputIterator2>
            bool includes(InputIterator1 first1, InputIterator1 last1,
                          InputIterator2 first2, InputIterator2 last2);
        template<class InputIterator1, class InputIterator2, class Compare>
            bool includes(
                InputIterator1 first1, InputIterator1 last1,
                InputIterator2 first2, InputIterator2 last2, Compare comp);
     
        template<class InputIterator1, class InputIterator2, class OutputIterator>
            OutputIterator set_union(InputIterator1 first1, InputIterator1 last1,
                                     InputIterator2 first2, InputIterator2 last2,
                                     OutputIterator result);
        template<class InputIterator1, class InputIterator2, class OutputIterator,
                 class Compare>
            OutputIterator set_union(InputIterator1 first1, InputIterator1 last1,
                                     InputIterator2 first2, InputIterator2 last2,
                                     OutputIterator result, Compare comp);
     
        template<class InputIterator1, class InputIterator2, class OutputIterator>
            OutputIterator set_intersection(
                InputIterator1 first1, InputIterator1 last1,
                InputIterator2 first2, InputIterator2 last2,
                OutputIterator result);
        template<class InputIterator1, class InputIterator2, class OutputIterator,
                 class Compare>
            OutputIterator set_intersection(
                InputIterator1 first1, InputIterator1 last1,
                InputIterator2 first2, InputIterator2 last2,
                OutputIterator result, Compare comp);
     
        template<class InputIterator1, class InputIterator2, class OutputIterator>
            OutputIterator set_difference(
                InputIterator1 first1, InputIterator1 last1,
                InputIterator2 first2, InputIterator2 last2,
                OutputIterator result);
        template<class InputIterator1, class InputIterator2, class OutputIterator,
                 class Compare>
            OutputIterator set_difference(
                InputIterator1 first1, InputIterator1 last1,
                InputIterator2 first2, InputIterator2 last2,
                OutputIterator result, Compare comp);
     
        template<class InputIterator1, class InputIterator2, class OutputIterator>
            OutputIterator set_symmetric_difference(
                InputIterator1 first1, InputIterator1 last1,
                InputIterator2 first2, InputIterator2 last2,
                OutputIterator result);
        template<class InputIterator1, class InputIterator2, class OutputIterator,
                 class Compare>
            OutputIterator set_symmetric_difference(
                InputIterator1 first1, InputIterator1 last1,
                InputIterator2 first2, InputIterator2 last2,
                OutputIterator result, Compare comp);
     
        // heap operations:
        template<class RandomAccessIterator>
            void push_heap(RandomAccessIterator first, RandomAccessIterator last);
        template<class RandomAccessIterator, class Compare>
            void push_heap(RandomAccessIterator first, RandomAccessIterator last,
                           Compare comp);
        template<class RandomAccessIterator>
            void pop_heap(RandomAccessIterator first, RandomAccessIterator last);
        template<class RandomAccessIterator, class Compare>
            void pop_heap(RandomAccessIterator first, RandomAccessIterator last,
                          Compare comp);
     
        template<class RandomAccessIterator>
            void make_heap(RandomAccessIterator first, RandomAccessIterator last);
        template<class RandomAccessIterator, class Compare>
            void make_heap(RandomAccessIterator first, RandomAccessIterator last,
                           Compare comp);
     
        template<class RandomAccessIterator>
            void sort_heap(RandomAccessIterator first, RandomAccessIterator last);
        template<class RandomAccessIterator, class Compare>
            void sort_heap(RandomAccessIterator first, RandomAccessIterator last,
                           Compare comp);
     
        template<class RandomAccessIterator>
            bool is_heap(RandomAccessIterator first, RandomAccessIterator last);
        template<class RandomAccessIterator, class Compare>
            bool is_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
        template<class RandomAccessIterator>
            RandomAccessIterator is_heap_until(RandomAccessIterator first, RandomAccessIterator last);
        template<class RandomAccessIterator, class Compare>
            RandomAccessIterator is_heap_until(RandomAccessIterator first, RandomAccessIterator last,
                                               Compare comp);
        // minimum and maximum:
        template<class T> const T& min(const T& a, const T& b);
        template<class T, class Compare>
            const T& min(const T& a, const T& b, Compare comp);
        template<class T>
            T min(initializer_list<T> t);
        template<class T, class Compare>
            T min(initializer_list<T> t, Compare comp);
     
        template<class T> const T& max(const T& a, const T& b);
        template<class T, class Compare>
            const T& max(const T& a, const T& b, Compare comp);
        template<class T>
            T max(initializer_list<T> t);
        template<class T, class Compare>
            T max(initializer_list<T> t, Compare comp);
     
        template<class T> pair<const T&, const T&> minmax(const T& a, const T& b);
        template<class T, class Compare>
            pair<const T&, const T&> minmax(const T& a, const T& b, Compare comp);
        template<class T>
            pair<T, T> minmax(initializer_list<T> t);
        template<class T, class Compare>
            pair<T, T> minmax(initializer_list<T> t, Compare comp);
     
        template<class ForwardIterator>
            ForwardIterator min_element(ForwardIterator first, ForwardIterator last);
        template<class ForwardIterator, class Compare>
            ForwardIterator min_element(ForwardIterator first, ForwardIterator last,
                                        Compare comp);
     
        template<class ForwardIterator>
            ForwardIterator max_element(ForwardIterator first, ForwardIterator last);
        template<class ForwardIterator, class Compare>
            ForwardIterator max_element(ForwardIterator first, ForwardIterator last,
                                        Compare comp);
     
        template<class ForwardIterator>
            pair<ForwardIterator, ForwardIterator>
            minmax_element(ForwardIterator first, ForwardIterator last);
        template<class ForwardIterator, class Compare>
            pair<ForwardIterator, ForwardIterator>
            minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
     
        template<class InputIterator1, class InputIterator2>
            bool lexicographical_compare(
                InputIterator1 first1, InputIterator1 last1,
                InputIterator2 first2, InputIterator2 last2);
        template<class InputIterator1, class InputIterator2, class Compare>
            bool lexicographical_compare(
                InputIterator1 first1, InputIterator1 last1,
                InputIterator2 first2, InputIterator2 last2,
                Compare comp);
     
        // permutations:
        template<class BidirectionalIterator>
            bool next_permutation(BidirectionalIterator first,
                                  BidirectionalIterator last);
        template<class BidirectionalIterator, class Compare>
            bool next_permutation(BidirectionalIterator first,
                                  BidirectionalIterator last, Compare comp);
     
        template<class BidirectionalIterator>
            bool prev_permutation(BidirectionalIterator first,
                                  BidirectionalIterator last);
        template<class BidirectionalIterator, class Compare>
            bool prev_permutation(BidirectionalIterator first,
                                  BidirectionalIterator last, Compare comp);
    }