achulkov2

Untitled

Feb 15th, 2018
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. template <typename It, typename OutputIt>
  2. OutputIt sideways_merge(It first1, It last1, It first2, It last2, OutputIt out) {
  3. while (first1 != last1 && first2 != last2) {
  4. if (*(first1) < *(first2)) {
  5. *(out++) = *(first1++);
  6. } else {
  7. *(out++) = *(first2++);
  8. }
  9. }
  10. while (first1 != last1) *(out++) = *(first1++);
  11. while (first2 != last2) *(out++) = *(first2++);
  12. return out;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment