summaryrefslogtreecommitdiff
path: root/include/libHX/intdiff.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/libHX/intdiff.hpp')
-rw-r--r--include/libHX/intdiff.hpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/libHX/intdiff.hpp b/include/libHX/intdiff.hpp
new file mode 100644
index 0000000..17300a1
--- /dev/null
+++ b/include/libHX/intdiff.hpp
@@ -0,0 +1,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