File indexing completed on 2025-01-18 09:28:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_ALGORITHM_IS_PERMUTATION14_HPP
0013 #define BOOST_ALGORITHM_IS_PERMUTATION14_HPP
0014
0015 #include <utility> // for std::pair
0016 #include <functional> // for std::equal_to
0017 #include <iterator>
0018
0019 #include <boost/config.hpp>
0020 #include <boost/algorithm/cxx11/is_permutation.hpp>
0021 #include <boost/algorithm/cxx14/mismatch.hpp>
0022
0023 namespace boost { namespace algorithm {
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 template< class ForwardIterator1, class ForwardIterator2 >
0035 bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
0036 ForwardIterator2 first2, ForwardIterator2 last2 )
0037 {
0038
0039
0040 std::pair<ForwardIterator1, ForwardIterator2> eq = boost::algorithm::mismatch
0041 ( first1, last1, first2, last2 );
0042 if ( eq.first == last1 && eq.second == last2)
0043 return true;
0044 return boost::algorithm::detail::is_permutation_tag (
0045 eq.first, last1, eq.second, last2,
0046 std::equal_to<typename std::iterator_traits<ForwardIterator1>::value_type> (),
0047 typename std::iterator_traits<ForwardIterator1>::iterator_category (),
0048 typename std::iterator_traits<ForwardIterator2>::iterator_category ());
0049 }
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 template< class ForwardIterator1, class ForwardIterator2, class BinaryPredicate >
0064 bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
0065 ForwardIterator2 first2, ForwardIterator2 last2,
0066 BinaryPredicate pred )
0067 {
0068 std::pair<ForwardIterator1, ForwardIterator2> eq = boost::algorithm::mismatch
0069 ( first1, last1, first2, last2, pred );
0070 if ( eq.first == last1 && eq.second == last2)
0071 return true;
0072 return boost::algorithm::detail::is_permutation_tag (
0073 first1, last1, first2, last2, pred,
0074 typename std::iterator_traits<ForwardIterator1>::iterator_category (),
0075 typename std::iterator_traits<ForwardIterator2>::iterator_category ());
0076 }
0077
0078 }}
0079
0080 #endif