tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
set_intersection.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_SET_INTERSECTION_HPP
4#define TETL_ALGORITHM_SET_INTERSECTION_HPP
5
7
8namespace etl {
9
12
20template <typename InputIt1, typename InputIt2, typename OutputIt, typename Compare>
21constexpr auto
22set_intersection(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt dest, Compare comp)
23 -> OutputIt
24{
25 while (first1 != last1 and first2 != last2) {
26 if (comp(*first1, *first2)) {
27 ++first1;
28 } else {
29 if (not comp(*first2, *first1)) {
30 *dest++ = *first1++;
31 }
32 ++first2;
33 }
34 }
35 return dest;
36}
37
38template <typename InputIt1, typename InputIt2, typename OutputIt>
39constexpr auto set_intersection(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt dest)
40 -> OutputIt
41{
42 return etl::set_intersection(first1, last1, first2, last2, dest, etl::less());
43}
44
46
47} // namespace etl
48
49#endif // TETL_ALGORITHM_SET_INTERSECTION_HPP
constexpr auto set_intersection(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt dest, Compare comp) -> OutputIt
Constructs a sorted range beginning at dest consisting of elements that are found in both sorted rang...
Definition set_intersection.hpp:22
Definition adjacent_find.hpp:8
Function object for performing comparisons. Unless specialised, invokes operator< on type T....
Definition less.hpp:14