set.hpp
Go to the documentation of this file.
00001 /* 00002 Copyright 2005-2007 Adobe Systems Incorporated 00003 Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt 00004 or a copy at http://stlab.adobe.com/licenses.html) 00005 */ 00006 00007 /*************************************************************************************************/ 00008 00009 #ifndef ADOBE_ALGORITHM_SET_HPP 00010 #define ADOBE_ALGORITHM_SET_HPP 00011 00012 #include <adobe/config.hpp> 00013 00014 #include <boost/range/begin.hpp> 00015 #include <boost/range/end.hpp> 00016 #include <boost/bind.hpp> 00017 00018 #include <algorithm> 00019 00020 /*************************************************************************************************/ 00021 00022 namespace adobe { 00023 00024 /*************************************************************************************************/ 00036 /*************************************************************************************************/ 00042 template <class InputRange1, class InputRange2> 00043 inline bool includes(const InputRange1& range1, const InputRange2& range2) 00044 { 00045 return std::includes( boost::begin(range1), boost::end(range1), 00046 boost::begin(range2), boost::end(range2)); 00047 } 00048 00054 template <class InputIterator1, class InputIterator2, class Compare> 00055 inline bool includes( InputIterator1 first1, InputIterator1 last1, 00056 InputIterator2 first2, InputIterator2 last2, 00057 Compare comp) 00058 00059 { 00060 return std::includes(first1, last1, first2, last2, boost::bind(comp, _1, _2)); 00061 } 00062 00068 template <class InputRange1, class InputRange2, class Compare> 00069 inline bool includes(const InputRange1& range1, const InputRange2& range2, Compare comp) 00070 { 00071 return adobe::includes( boost::begin(range1), boost::end(range1), 00072 boost::begin(range2), boost::end(range2), 00073 comp); 00074 } 00075 00081 template <class InputRange1, class InputRange2, class OutputIterator> 00082 inline OutputIterator set_union(const InputRange1& range1, const InputRange2& range2, OutputIterator result) 00083 { 00084 return std::set_union( boost::begin(range1), boost::end(range1), 00085 boost::begin(range2), boost::end(range2), 00086 result); 00087 } 00088 00094 template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> 00095 inline OutputIterator set_union(InputIterator1 first1, InputIterator1 last1, 00096 InputIterator2 first2, InputIterator2 last2, 00097 OutputIterator result, Compare comp) 00098 { 00099 return std::set_union(first1, last1, first2, last2, result, boost::bind(comp, _1, _2)); 00100 } 00101 00107 template <class InputRange1, class InputRange2, class OutputIterator, class Compare> 00108 inline OutputIterator set_union(const InputRange1& range1, const InputRange2& range2, OutputIterator result, Compare comp) 00109 { 00110 return adobe::set_union(boost::begin(range1), boost::end(range1), 00111 boost::begin(range2), boost::end(range2), 00112 result, comp); 00113 } 00114 00120 template <class InputRange1, class InputRange2, class OutputIterator> 00121 inline OutputIterator set_intersection(const InputRange1& range1, const InputRange2& range2, OutputIterator result) 00122 { 00123 return std::set_intersection( boost::begin(range1), boost::end(range1), 00124 boost::begin(range2), boost::end(range2), 00125 result); 00126 } 00127 00133 template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> 00134 inline OutputIterator set_intersection( InputIterator1 first1, InputIterator1 last1, 00135 InputIterator2 first2, InputIterator2 last2, 00136 OutputIterator result, Compare comp) 00137 { 00138 return std::set_intersection(first1, last1, first2, last2, result, boost::bind(comp, _1, _2)); 00139 } 00140 00146 template <class InputRange1, class InputRange2, class OutputIterator, class Compare> 00147 inline OutputIterator set_intersection(const InputRange1& range1, const InputRange2& range2, OutputIterator result, Compare comp) 00148 { 00149 return adobe::set_intersection( boost::begin(range1), boost::end(range1), 00150 boost::begin(range2), boost::end(range2), 00151 result, comp); 00152 } 00153 00159 template <class InputRange1, class InputRange2, class OutputIterator> 00160 inline OutputIterator set_difference(const InputRange1& range1, const InputRange2& range2, OutputIterator result) 00161 { 00162 return std::set_difference( boost::begin(range1), boost::end(range1), 00163 boost::begin(range2), boost::end(range2), 00164 result); 00165 } 00166 00172 template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> 00173 inline OutputIterator set_difference( InputIterator1 first1, InputIterator1 last1, 00174 InputIterator2 first2, InputIterator2 last2, 00175 OutputIterator result, Compare comp) 00176 { 00177 return std::set_difference(first1, last1, first2, last2, result, boost::bind(comp, _1, _2)); 00178 } 00179 00185 template <class InputRange1, class InputRange2, class OutputIterator, class Compare> 00186 inline OutputIterator set_difference(const InputRange1& range1, const InputRange2& range2, OutputIterator result, Compare comp) 00187 { 00188 return adobe::set_difference( boost::begin(range1), boost::end(range1), 00189 boost::begin(range2), boost::end(range2), 00190 result, comp); 00191 } 00192 00198 template <class InputRange1, class InputRange2, class OutputIterator> 00199 inline OutputIterator set_symmetric_difference(const InputRange1& range1, const InputRange2& range2, OutputIterator result) 00200 { 00201 return std::set_symmetric_difference( boost::begin(range1), boost::end(range1), 00202 boost::begin(range2), boost::end(range2), 00203 result); 00204 } 00205 00211 template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare> 00212 inline OutputIterator set_symmetric_difference( InputIterator1 first1, InputIterator1 last1, 00213 InputIterator2 first2, InputIterator2 last2, 00214 OutputIterator result, Compare comp) 00215 { 00216 return std::set_symmetric_difference(first1, last1, first2, last2, result, boost::bind(comp, _1, _2)); 00217 } 00218 00224 template <class InputRange1, class InputRange2, class OutputIterator, class Compare> 00225 inline OutputIterator set_symmetric_difference(const InputRange1& range1, const InputRange2& range2, OutputIterator result, Compare comp) 00226 { 00227 return adobe::set_symmetric_difference( boost::begin(range1), boost::end(range1), 00228 boost::begin(range2), boost::end(range2), 00229 result, comp); 00230 } 00231 00232 /*************************************************************************************************/ 00233 00234 } // namespace adobe 00235 00236 /*************************************************************************************************/ 00237 00238 #endif 00239 00240 /*************************************************************************************************/ |