6 #ifndef TURI_ALGORITHMIC_UTILS_H_ 7 #define TURI_ALGORITHMIC_UTILS_H_ 10 #include <core/logging/assertions.hpp> 37 template <
typename InputIterator1,
typename InputIterator2,
38 typename ComparisonFunction,
typename AccumulateFunction>
40 InputIterator2 first2,
const InputIterator2& last2,
41 const ComparisonFunction& less_than_operator,
42 const AccumulateFunction& accumulate_matching_pair) {
44 DASSERT_TRUE(std::is_sorted(first1, last1, less_than_operator));
45 DASSERT_TRUE(std::is_sorted(first2, last2, less_than_operator));
47 while (first1 != last1 && first2 != last2) {
48 if (less_than_operator(*first1, *first2) ) {
50 }
else if (less_than_operator(*first2, *first1) ) {
53 accumulate_matching_pair(*first1, *first2);
79 template <
typename InputIterator1,
typename InputIterator2,
typename AccumulateFunction>
81 InputIterator2 first2,
const InputIterator2& last2,
82 const AccumulateFunction& accumulate_matching_pair) {
84 typedef typename std::remove_reference<decltype(*first1)>::type value1_type;
85 typedef typename std::remove_reference<decltype(*first2)>::type value2_type;
88 [](
const value1_type& v1,
89 const value2_type& v2)
91 accumulate_matching_pair);
113 template <
typename InputIterator1,
typename InputIterator2>
115 InputIterator2 first2,
const InputIterator2& last2) {
117 typedef typename std::remove_reference<decltype(*first1)>::type value1_type;
118 typedef typename std::remove_reference<decltype(*first2)>::type value2_type;
122 [&](
const value1_type&,
const value2_type&)
151 template <
typename InputIterator1,
typename InputIterator2,
typename ComparisonFunction>
153 InputIterator2 first2,
const InputIterator2& last2,
154 const ComparisonFunction& less_than_operator) {
156 typedef typename std::remove_reference<decltype(*first1)>::type value1_type;
157 typedef typename std::remove_reference<decltype(*first2)>::type value2_type;
162 [&](
const value1_type&,
const value2_type&)
#define DASSERT_TRUE(cond)