/* Copyright (C) 2015 Povilas Kanapickas
This file is part of cppreference-doc
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
Unported License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
*/
#ifndef CPPREFERENCE_ALGORITHM_H
#define CPPREFERENCE_ALGORITHM_H
#if CPPREFERENCE_STDVER >= 2011
#include
#endif
#include // for std::pair
namespace std {
#if CPPREFERENCE_STDVER >= 2011
template
bool all_of(InputIt first, InputIt last, UnaryPredicate p);
template
bool any_of(InputIt first, InputIt last, UnaryPredicate p);
template
bool none_of(InputIt first, InputIt last, UnaryPredicate p);
#endif
template
UnaryFunction for_each(InputIt first, InputIt last, UnaryFunction f);
template
typename iterator_traits::difference_type
count(InputIt first, InputIt last, const T& value);
template
typename iterator_traits::difference_type
count_if(InputIt first, InputIt last, UnaryPredicate p);
template
std::pair
mismatch(InputIt1 first1, InputIt1 last1,
InputIt2 first2);
template
std::pair
mismatch(InputIt1 first1, InputIt1 last1,
InputIt2 first2,
BinaryPredicate p);
#if CPPREFERENCE_STDVER >= 2014
template
std::pair
mismatch(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2);
template
std::pair
mismatch(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
BinaryPredicate p);
#endif
template
bool equal(InputIt1 first1, InputIt1 last1,
InputIt2 first2);
template
bool equal(InputIt1 first1, InputIt1 last1,
InputIt2 first2, BinaryPredicate p);
#if CPPREFERENCE_STDVER >= 2014
template
bool equal(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2);
template
bool equal(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
BinaryPredicate p);
#endif
template
InputIt find(InputIt first, InputIt last, const T& value);
template
InputIt find_if(InputIt first, InputIt last,
UnaryPredicate p);
#if CPPREFERENCE_STDVER >= 2011
template
InputIt find_if_not(InputIt first, InputIt last,
UnaryPredicate q);
#endif
template
ForwardIt1 find_end(ForwardIt1 first, ForwardIt1 last,
ForwardIt2 s_first, ForwardIt2 s_last);
template
ForwardIt1 find_end(ForwardIt1 first, ForwardIt1 last,
ForwardIt2 s_first, ForwardIt2 s_last, BinaryPredicate p);
#if CPPREFERENCE_STDVER >= 2011
template
InputIt find_first_of(InputIt first, InputIt last,
ForwardIt s_first, ForwardIt s_last);
template
InputIt find_first_of(InputIt first, InputIt last,
ForwardIt s_first, ForwardIt s_last, BinaryPredicate p);
#else
template
ForwardIt1 find_first_of(ForwardIt1 first, ForwardIt1 last,
ForwardIt2 s_first, ForwardIt2 s_last);
template
ForwardIt1 find_first_of(ForwardIt1 first, ForwardIt1 last,
ForwardIt2 s_first, ForwardIt2 s_last, BinaryPredicate p);
#endif
template
ForwardIt adjacent_find(ForwardIt first, ForwardIt last);
template
ForwardIt adjacent_find(ForwardIt first, ForwardIt last, BinaryPredicate p);
template
ForwardIt1 search(ForwardIt1 first, ForwardIt1 last,
ForwardIt2 s_first, ForwardIt2 s_last);
template
ForwardIt1 search(ForwardIt1 first, ForwardIt1 last,
ForwardIt2 s_first, ForwardIt2 s_last, BinaryPredicate p);
template
ForwardIt search_n(ForwardIt first, ForwardIt last, Size count, const T& value);
template
ForwardIt search_n(ForwardIt first, ForwardIt last, Size count, const T& value,
BinaryPredicate p);
template
OutputIt copy(InputIt first, InputIt last, OutputIt d_first);
#if CPPREFERENCE_STDVER >= 2011
template
OutputIt copy_if(InputIt first, InputIt last,
OutputIt d_first,
UnaryPredicate pred);
#endif
#if CPPREFERENCE_STDVER >= 2011
template
OutputIt copy_n(InputIt first, Size count, OutputIt result);
#endif
template
BidirIt2 copy_backward(BidirIt1 first, BidirIt1 last, BidirIt2 d_last);
#if CPPREFERENCE_STDVER >= 2011
template
OutputIt move(InputIt first, InputIt last, OutputIt d_first);
#endif
#if CPPREFERENCE_STDVER >= 2011
template
OutputIt move(InputIt first, InputIt last, OutputIt d_first);
#endif
template
void fill(ForwardIt first, ForwardIt last, const T& value);
#if CPPREFERENCE_STDVER >= 2011
template
OutputIt fill_n(OutputIt first, Size count, const T& value);
#else
template
void fill_n(OutputIt first, Size count, const T& value);
#endif
template
OutputIt transform(InputIt first1, InputIt last1, OutputIt d_first,
UnaryOperation unary_op);
template
OutputIt transform(InputIt1 first1, InputIt1 last1, InputIt2 first2,
OutputIt d_first, BinaryOperation binary_op);
template
void generate(ForwardIt first, ForwardIt last, Generator g);
#if CPPREFERENCE_STDVER >= 2011
template
OutputIt generate_n(OutputIt first, Size count, Generator g);
#else
template
void generate_n(OutputIt first, Size count, Generator g);
#endif
template
ForwardIt remove(ForwardIt first, ForwardIt last, const T& value);
template
ForwardIt remove_if(ForwardIt first, ForwardIt last, UnaryPredicate p);
template
OutputIt remove_copy(InputIt first, InputIt last, OutputIt d_first,
const T& value);
template
OutputIt remove_copy_if(InputIt first, InputIt last, OutputIt d_first,
UnaryPredicate p);
template
OutputIt remove_copy_if(InputIt first, InputIt last, OutputIt d_first,
UnaryPredicate p);
template
void replace_if(ForwardIt first, ForwardIt last,
UnaryPredicate p, const T& new_value);
template
OutputIt replace_copy(InputIt first, InputIt last, OutputIt d_first,
const T& old_value, const T& new_value);
template
OutputIt replace_copy_if(InputIt first, InputIt last, OutputIt d_first,
UnaryPredicate p, const T& new_value);
// defined in in C++11
#if CPPREFERENCE_STDVER >= 2011
template
void swap(T& a, T& b);
#endif
template
ForwardIt2 swap_ranges(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2);
template
void iter_swap(ForwardIt1 a, ForwardIt2 b);
template
void reverse(BidirIt first, BidirIt last);
template
OutputIt reverse_copy(BidirIt first, BidirIt last, OutputIt d_first);
#if CPPREFERENCE_STDVER >= 2011
template
ForwardIt rotate(ForwardIt first, ForwardIt n_first, ForwardIt last);
#else
template
void rotate(ForwardIt first, ForwardIt n_first, ForwardIt last);
#endif
template
OutputIt rotate_copy(ForwardIt first, ForwardIt n_first,
ForwardIt last, OutputIt d_first);
#if CPPREFERENCE_STDVER <2017
// deprecated in C++14
template
void random_shuffle(RandomIt first, RandomIt last);
#endif
#if CPPREFERENCE_STDVER <2011
template
void random_shuffle(RandomIt first, RandomIt last, RandomFunc&& r);
#elif CPPREFERENCE_STDVER >= 2011 && CPPREFERENCE_STDVER <2017
// deprecated in C++14
template
void random_shuffle(RandomIt first, RandomIt last, RandomFunc& r);
#endif
#if CPPREFERENCE_STDVER >= 2011
template
void shuffle(RandomIt first, RandomIt last, URNG&& g);
#endif
template
ForwardIt unique(ForwardIt first, ForwardIt last);
template
ForwardIt unique(ForwardIt first, ForwardIt last, BinaryPredicate p);
template
OutputIt unique_copy(InputIt first, InputIt last,
OutputIt d_first);
template
OutputIt unique_copy(InputIt first, InputIt last,
OutputIt d_first, BinaryPredicate p);
#if CPPREFERENCE_STDVER >= 2011
template
bool is_partitioned(InputIt first, InputIt last, UnaryPredicate p);
#endif
#if CPPREFERENCE_STDVER <2011
template
BidirIt partition(BidirIt first, BidirIt last, UnaryPredicate p);
#else
template
ForwardIt partition(ForwardIt first, ForwardIt last, UnaryPredicate p);
#endif
#if CPPREFERENCE_STDVER >= 2011
template
std::pair
partition_copy(InputIt first, InputIt last,
OutputIt1 d_first_true, OutputIt2 d_first_false,
UnaryPredicate p);
#endif
template
BidirIt stable_partition(BidirIt first, BidirIt last, UnaryPredicate p);
#if CPPREFERENCE_STDVER >= 2011
template
ForwardIt partition_point(ForwardIt first, ForwardIt last, UnaryPredicate p);
#endif
#if CPPREFERENCE_STDVER >= 2011
template
bool is_sorted(ForwardIt first, ForwardIt last);
template
bool is_sorted(ForwardIt first, ForwardIt last, Compare comp);
template
ForwardIt is_sorted_until(ForwardIt first, ForwardIt last);
template
ForwardIt is_sorted_until(ForwardIt first, ForwardIt last,
Compare comp);
#endif
template
void sort(RandomIt first, RandomIt last);
template
void sort(RandomIt first, RandomIt last, Compare comp);
template
void partial_sort(RandomIt first, RandomIt middle, RandomIt last);
template
void partial_sort(RandomIt first, RandomIt middle, RandomIt last, Compare comp);
template
RandomIt partial_sort_copy(InputIt first, InputIt last,
RandomIt d_first, RandomIt d_last);
template
RandomIt partial_sort_copy(InputIt first, InputIt last,
RandomIt d_first, RandomIt d_last,
Compare comp);
template
void stable_sort(RandomIt first, RandomIt last);
template
void stable_sort(RandomIt first, RandomIt last, Compare comp);
template
void nth_element(RandomIt first, RandomIt nth, RandomIt last);
template
void nth_element(RandomIt first, RandomIt nth, RandomIt last, Compare comp);
template
ForwardIt lower_bound(ForwardIt first, ForwardIt last, const T& value);
template
ForwardIt lower_bound(ForwardIt first, ForwardIt last, const T& value, Compare comp);
template
ForwardIt upper_bound(ForwardIt first, ForwardIt last, const T& value);
template
ForwardIt upper_bound(ForwardIt first, ForwardIt last, const T& value, Compare comp);
template
bool binary_search(ForwardIt first, ForwardIt last, const T& value);
template
bool binary_search(ForwardIt first, ForwardIt last, const T& value, Compare comp);
template
std::pair
equal_range(ForwardIt first, ForwardIt last,
const T& value);
template
std::pair
equal_range(ForwardIt first, ForwardIt last,
const T& value, Compare comp);
template
OutputIt merge(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first);
template
OutputIt merge(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first, Compare comp);
template
void inplace_merge(BidirIt first, BidirIt middle, BidirIt last);
template
void inplace_merge(BidirIt first, BidirIt middle, BidirIt last, Compare comp);
template
bool includes(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2);
template
bool includes(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2, Compare comp);
template
OutputIt set_difference(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first);
template
OutputIt set_difference(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first, Compare comp);
template
OutputIt set_intersection(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first);
template
OutputIt set_intersection(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first, Compare comp);
template
OutputIt set_symmetric_difference(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first);
template
OutputIt set_symmetric_difference(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first, Compare comp);
template
OutputIt set_union(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first);
template
OutputIt set_union(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
OutputIt d_first, Compare comp);
#if CPPREFERENCE_STDVER >= 2011
template
bool is_heap(RandomIt first, RandomIt last);
template
bool is_heap(RandomIt first, RandomIt last, Compare comp);
template
RandomIt is_heap_until(RandomIt first, RandomIt last);
template
RandomIt is_heap_until(RandomIt first, RandomIt last, Compare comp);
#endif
template
void make_heap(RandomIt first, RandomIt last);
template
void make_heap(RandomIt first, RandomIt last,
Compare comp);
template
void push_heap(RandomIt first, RandomIt last);
template
void push_heap(RandomIt first, RandomIt last,
Compare comp);
template
void pop_heap(RandomIt first, RandomIt last);
template
void pop_heap(RandomIt first, RandomIt last, Compare comp);
template
void sort_heap(RandomIt first, RandomIt last);
template
void sort_heap(RandomIt first, RandomIt last, Compare comp);
#if CPPREFERENCE_STDVER <2014
template
const T& max(const T& a, const T& b);
template
const T& max(const T& a, const T& b, Compare comp);
#else
template
constexpr const T& max(const T& a, const T& b);
template
constexpr const T& max(const T& a, const T& b, Compare comp);
#endif
#if CPPREFERENCE_STDVER >= 2011
template
T max(std::initializer_list ilist);
template
T max(std::initializer_list ilist, Compare comp);
#elif CPPREFERENCE_STDVER >= 2014
template
constexpr T max(std::initializer_list ilist);
template
constexpr T max(std::initializer_list ilist, Compare comp);
#endif
#if CPPREFERENCE_STDVER <2017
template
ForwardIt max_element(ForwardIt first, ForwardIt last);
template
ForwardIt max_element(ForwardIt first, ForwardIt last, Compare cmp);
#else
template
constexpr ForwardIt max_element(ForwardIt first, ForwardIt last);
template
constexpr ForwardIt max_element(ForwardIt first, ForwardIt last, Compare cmp);
#endif
#if CPPREFERENCE_STDVER <2014
template
const T& min(const T& a, const T& b);
template
const T& min(const T& a, const T& b, Compare comp);
#else
template
constexpr const T& min(const T& a, const T& b);
template
constexpr const T& min(const T& a, const T& b, Compare comp);
#endif
#if CPPREFERENCE_STDVER >= 2011
template
T min(std::initializer_list ilist);
template
T min(std::initializer_list ilist, Compare comp);
#elif CPPREFERENCE_STDVER >= 2014
template
constexpr T min(std::initializer_list ilist);
template
constexpr T min(std::initializer_list ilist, Compare comp);
#endif
#if CPPREFERENCE_STDVER <2017
template
ForwardIt min_element(ForwardIt first, ForwardIt last);
template
ForwardIt min_element(ForwardIt first, ForwardIt last, Compare cmp);
#else
template
constexpr ForwardIt min_element(ForwardIt first, ForwardIt last);
template
constexpr ForwardIt min_element(ForwardIt first, ForwardIt last, Compare cmp);
#endif
#if CPPREFERENCE_STDVER >= 2011 && CPPREFERENCE_STDVER <2014
template
std::pair minmax(const T& a, const T& b);
template
std::pair minmax(const T& a, const T& b,
Compare comp);
template
std::pair minmax(std::initializer_list ilist);
template
std::pair minmax(std::initializer_list ilist, Compare comp);
#elif CPPREFERENCE_STDVER >= 2014
template
constexpr std::pair minmax(const T& a, const T& b);
template
constexpr std::pair minmax(const T& a, const T& b,
Compare comp);
template
constexpr std::pair minmax(std::initializer_list ilist);
template
constexpr std::pair minmax(std::initializer_list ilist, Compare comp);
#endif
#if CPPREFERENCE_STDVER >= 2011 && CPPREFERENCE_STDVER <2017
template
std::pair
minmax_element(ForwardIt first, ForwardIt last);
template
std::pair
minmax_element(ForwardIt first, ForwardIt last, Compare comp);
#elif CPPREFERENCE_STDVER >= 2017
template
constexpr std::pair
minmax_element(ForwardIt first, ForwardIt last);
template
constexpr std::pair
minmax_element(ForwardIt first, ForwardIt last, Compare comp);
#endif
template
bool lexicographical_compare(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2);
template
bool lexicographical_compare(InputIt1 first1, InputIt1 last1,
InputIt2 first2, InputIt2 last2,
Compare comp);
#if CPPREFERENCE_STDVER >= 2011
template
bool is_permutation(ForwardIt1 first1, ForwardIt1 last1,
ForwardIt2 first2);
template
bool is_permutation(ForwardIt1 first1, ForwardIt1 last1,
ForwardIt2 first2, BinaryPredicate p);
#endif
#if CPPREFERENCE_STDVER >= 2011
template
bool is_permutation(ForwardIt1 first1, ForwardIt1 last1,
ForwardIt2 first2, ForwardIt2 last2);
template
bool is_permutation(ForwardIt1 first1, ForwardIt1 last1,
ForwardIt2 first2, ForwardIt2 last2,
BinaryPredicate p);
#endif
template
bool next_permutation(BidirIt first, BidirIt last);
template
bool next_permutation(BidirIt first, BidirIt last, Compare comp);
template
bool prev_permutation(BidirIt first, BidirIt last);
template
bool prev_permutation(BidirIt first, BidirIt last, Compare comp);
} // namespace std
#endif // CPPREFERENCE_ALGORITHM_H