tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
set_symmetric_difference.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_SET_SYMMETRIC_DIFFERENCE_HPP
4#define TETL_ALGORITHM_SET_SYMMETRIC_DIFFERENCE_HPP
5
8
9namespace etl {
10
13
17template <typename InputIt1, typename InputIt2, typename OutputIt, typename Compare>
19 InputIt1 first1,
20 InputIt1 last1,
21 InputIt2 first2,
22 InputIt2 last2,
23 OutputIt destination,
24 Compare comp
25) -> OutputIt
26{
27 while (first1 != last1) {
28 if (first2 == last2) {
29 return etl::copy(first1, last1, destination);
30 }
31
32 if (comp(*first1, *first2)) {
33 *destination++ = *first1++;
34 } else {
35 if (comp(*first2, *first1)) {
36 *destination++ = *first2;
37 } else {
38 ++first1;
39 }
40 ++first2;
41 }
42 }
43 return etl::copy(first2, last2, destination);
44}
45
46template <typename InputIt1, typename InputIt2, typename OutputIt>
47constexpr auto set_symmetric_difference(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt dest)
48 -> OutputIt
49{
50 return etl::set_symmetric_difference(first1, last1, first2, last2, dest, etl::less());
51}
52
54
55} // namespace etl
56
57#endif // TETL_ALGORITHM_SET_SYMMETRIC_DIFFERENCE_HPP
constexpr auto set_symmetric_difference(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt destination, Compare comp) -> OutputIt
Computes symmetric difference of two sorted ranges: the elements that are found in either of the rang...
Definition set_symmetric_difference.hpp:18
constexpr auto copy(InputIt first, InputIt last, OutputIt destination) -> OutputIt
Copies the elements in the range, defined by [first, last), to another range beginning at destination...
Definition copy.hpp:18
Definition adjacent_find.hpp:8
Function object for performing comparisons. Unless specialised, invokes operator< on type T....
Definition less.hpp:14