File: intdiff.hpp

package info (click to toggle)
libhx 5.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,664 kB
  • sloc: ansic: 10,332; sh: 5,230; cpp: 133; makefile: 116
file content (24 lines) | stat: -rw-r--r-- 611 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef LIBHX_INTDIFF_HPP
#define LIBHX_INTDIFF_HPP 1
#include <algorithm>
namespace HX {
template<typename AIter, typename BIter, typename XIter,
         typename YIter, typename ZIter>
void set_intersect_diff(AIter a_first, AIter a_last, BIter b_first,
    BIter b_last, XIter xptr, YIter yptr, ZIter zptr)
{
	while ((a_first != a_last) && (b_first != b_last)) {
		if (*a_first < *b_first)
			*xptr++ = *a_first++;
		else if (*b_first < *a_first)
			*yptr++ = *b_first++;
		else {
			*zptr++ = *a_first++;
			++b_first;
		}
	}
	std::copy(a_first, a_last, xptr);
	std::copy(b_first, b_last, yptr);
}
}
#endif