Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
set.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5*/
6/**************************************************************************************************/
7
8#ifndef ADOBE_ALGORITHM_SET_HPP
9#define ADOBE_ALGORITHM_SET_HPP
10
11#include <adobe/config.hpp>
12
13#include <boost/range/begin.hpp>
14#include <boost/range/end.hpp>
15
16#include <algorithm>
17#include <functional>
18
19/**************************************************************************************************/
20
21namespace adobe {
22
23/**************************************************************************************************/
35/**************************************************************************************************/
41template <class InputRange1, class InputRange2>
42inline bool includes(const InputRange1& range1, const InputRange2& range2) {
43 return std::includes(boost::begin(range1), boost::end(range1), boost::begin(range2),
44 boost::end(range2));
45}
46
52template <class InputIterator1, class InputIterator2, class Compare>
53inline bool includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
54 InputIterator2 last2, Compare comp) {
55 return std::includes(first1, last1, first2, last2,
56 std::bind(comp, std::placeholders::_1, std::placeholders::_2));
57}
58
64template <class InputRange1, class InputRange2, class Compare>
65inline bool includes(const InputRange1& range1, const InputRange2& range2, Compare comp) {
66 return adobe::includes(boost::begin(range1), boost::end(range1), boost::begin(range2),
67 boost::end(range2), comp);
68}
69
75template <class InputRange1, class InputRange2, class OutputIterator>
76inline OutputIterator set_union(const InputRange1& range1, const InputRange2& range2,
77 OutputIterator result) {
78 return std::set_union(boost::begin(range1), boost::end(range1), boost::begin(range2),
79 boost::end(range2), result);
80}
81
87template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
88inline OutputIterator set_union(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
89 InputIterator2 last2, OutputIterator result, Compare comp) {
90 return std::set_union(first1, last1, first2, last2, result,
91 std::bind(comp, std::placeholders::_1, std::placeholders::_2));
92}
93
99template <class InputRange1, class InputRange2, class OutputIterator, class Compare>
100inline OutputIterator set_union(const InputRange1& range1, const InputRange2& range2,
101 OutputIterator result, Compare comp) {
102 return adobe::set_union(boost::begin(range1), boost::end(range1), boost::begin(range2),
103 boost::end(range2), result, comp);
104}
105
111template <class InputRange1, class InputRange2, class OutputIterator>
112inline OutputIterator set_intersection(const InputRange1& range1, const InputRange2& range2,
113 OutputIterator result) {
114 return std::set_intersection(boost::begin(range1), boost::end(range1), boost::begin(range2),
115 boost::end(range2), result);
116}
117
123template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
124inline OutputIterator set_intersection(InputIterator1 first1, InputIterator1 last1,
125 InputIterator2 first2, InputIterator2 last2,
126 OutputIterator result, Compare comp) {
127 return std::set_intersection(first1, last1, first2, last2, result,
128 std::bind(comp, std::placeholders::_1, std::placeholders::_2));
129}
130
136template <class InputRange1, class InputRange2, class OutputIterator, class Compare>
137inline OutputIterator set_intersection(const InputRange1& range1, const InputRange2& range2,
138 OutputIterator result, Compare comp) {
139 return adobe::set_intersection(boost::begin(range1), boost::end(range1), boost::begin(range2),
140 boost::end(range2), result, comp);
141}
142
148template <class InputRange1, class InputRange2, class OutputIterator>
149inline OutputIterator set_difference(const InputRange1& range1, const InputRange2& range2,
150 OutputIterator result) {
151 return std::set_difference(boost::begin(range1), boost::end(range1), boost::begin(range2),
152 boost::end(range2), result);
153}
154
160template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
161inline OutputIterator set_difference(InputIterator1 first1, InputIterator1 last1,
162 InputIterator2 first2, InputIterator2 last2,
163 OutputIterator result, Compare comp) {
164 return std::set_difference(first1, last1, first2, last2, result,
165 std::bind(comp, std::placeholders::_1, std::placeholders::_2));
166}
167
173template <class InputRange1, class InputRange2, class OutputIterator, class Compare>
174inline OutputIterator set_difference(const InputRange1& range1, const InputRange2& range2,
175 OutputIterator result, Compare comp) {
176 return adobe::set_difference(boost::begin(range1), boost::end(range1), boost::begin(range2),
177 boost::end(range2), result, comp);
178}
179
185template <class InputRange1, class InputRange2, class OutputIterator>
186inline OutputIterator set_symmetric_difference(const InputRange1& range1, const InputRange2& range2,
187 OutputIterator result) {
188 return std::set_symmetric_difference(boost::begin(range1), boost::end(range1),
189 boost::begin(range2), boost::end(range2), result);
190}
191
197template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
198inline OutputIterator set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
199 InputIterator2 first2, InputIterator2 last2,
200 OutputIterator result, Compare comp) {
201 return std::set_symmetric_difference(
202 first1, last1, first2, last2, result,
203 std::bind(comp, std::placeholders::_1, std::placeholders::_2));
204}
205
211template <class InputRange1, class InputRange2, class OutputIterator, class Compare>
212inline OutputIterator set_symmetric_difference(const InputRange1& range1, const InputRange2& range2,
213 OutputIterator result, Compare comp) {
214 return adobe::set_symmetric_difference(boost::begin(range1), boost::end(range1),
215 boost::begin(range2), boost::end(range2), result, comp);
216}
217
218/**************************************************************************************************/
219
220} // namespace adobe
221
222/**************************************************************************************************/
223
224#endif
225
226/**************************************************************************************************/
OutputIterator set_union(const InputRange1 &range1, const InputRange2 &range2, OutputIterator result)
set implementation
Definition set.hpp:76
bool includes(const InputRange1 &range1, const InputRange2 &range2)
set implementation
Definition set.hpp:42
OutputIterator set_symmetric_difference(const InputRange1 &range1, const InputRange2 &range2, OutputIterator result)
set implementation
Definition set.hpp:186
OutputIterator set_difference(const InputRange1 &range1, const InputRange2 &range2, OutputIterator result)
set implementation
Definition set.hpp:149
OutputIterator set_intersection(const InputRange1 &range1, const InputRange2 &range2, OutputIterator result)
set implementation
Definition set.hpp:112