Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:59:17

0001 //  Copyright Neil Groves 2009. Use, modification and
0002 //  distribution is subject to the Boost Software License, Version
0003 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 //
0006 //
0007 // For more information, see http://www.boost.org/libs/range/
0008 //
0009 #ifndef BOOST_RANGE_ALGORITHM_SET_ALGORITHM_HPP_INCLUDED
0010 #define BOOST_RANGE_ALGORITHM_SET_ALGORITHM_HPP_INCLUDED
0011 
0012 #include <boost/concept_check.hpp>
0013 #include <boost/range/begin.hpp>
0014 #include <boost/range/end.hpp>
0015 #include <boost/range/concepts.hpp>
0016 #include <algorithm>
0017 
0018 namespace boost
0019 {
0020     namespace range
0021     {
0022 
0023 /// \brief template function includes
0024 ///
0025 /// range-based version of the includes std algorithm
0026 ///
0027 /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
0028 /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
0029 /// \pre BinaryPredicate is a model of the BinaryPredicateConcept
0030 template<class SinglePassRange1, class SinglePassRange2>
0031 inline bool includes(const SinglePassRange1& rng1,
0032                      const SinglePassRange2& rng2)
0033 {
0034     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0035     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
0036     return std::includes(boost::begin(rng1),boost::end(rng1),
0037                          boost::begin(rng2),boost::end(rng2));
0038 }
0039 
0040 /// \overload
0041 template<class SinglePassRange1, class SinglePassRange2,
0042          class BinaryPredicate>
0043 inline bool includes(const SinglePassRange1& rng1,
0044                      const SinglePassRange2& rng2,
0045                      BinaryPredicate         pred)
0046 {
0047     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0048     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
0049     return std::includes(boost::begin(rng1), boost::end(rng1),
0050                          boost::begin(rng2), boost::end(rng2), pred);
0051 }
0052 
0053 /// \brief template function set_union
0054 ///
0055 /// range-based version of the set_union std algorithm
0056 ///
0057 /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
0058 /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
0059 /// \pre BinaryPredicate is a model of the BinaryPredicateConcept
0060 template<class SinglePassRange1, class SinglePassRange2,
0061          class OutputIterator>
0062 inline OutputIterator set_union(const SinglePassRange1& rng1,
0063                                 const SinglePassRange2& rng2,
0064                                 OutputIterator          out)
0065 {
0066     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0067     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
0068     return std::set_union(boost::begin(rng1), boost::end(rng1),
0069                           boost::begin(rng2), boost::end(rng2), out);
0070 }
0071 
0072 /// \overload
0073 template<class SinglePassRange1, class SinglePassRange2,
0074          class OutputIterator, class BinaryPredicate>
0075 inline OutputIterator set_union(const SinglePassRange1& rng1,
0076                                 const SinglePassRange2& rng2,
0077                                 OutputIterator          out,
0078                                 BinaryPredicate         pred)
0079 {
0080     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0081     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
0082     return std::set_union(boost::begin(rng1), boost::end(rng1),
0083                           boost::begin(rng2), boost::end(rng2), out, pred);
0084 }
0085 
0086 /// \brief template function set_intersection
0087 ///
0088 /// range-based version of the set_intersection std algorithm
0089 ///
0090 /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
0091 /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
0092 /// \pre BinaryPredicate is a model of the BinaryPredicateConcept
0093 template<class SinglePassRange1, class SinglePassRange2,
0094          class OutputIterator>
0095 inline OutputIterator set_intersection(const SinglePassRange1& rng1,
0096                                        const SinglePassRange2& rng2,
0097                                        OutputIterator          out)
0098 {
0099     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0100     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
0101     return std::set_intersection(boost::begin(rng1), boost::end(rng1),
0102                                  boost::begin(rng2), boost::end(rng2), out);
0103 }
0104 
0105 /// \overload
0106 template<class SinglePassRange1, class SinglePassRange2,
0107          class OutputIterator, class BinaryPredicate>
0108 inline OutputIterator set_intersection(const SinglePassRange1& rng1,
0109                                        const SinglePassRange2& rng2,
0110                                        OutputIterator          out,
0111                                        BinaryPredicate         pred)
0112 {
0113     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0114     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
0115     return std::set_intersection(boost::begin(rng1), boost::end(rng1),
0116                                  boost::begin(rng2), boost::end(rng2),
0117                                  out, pred);
0118 }
0119 
0120 /// \brief template function set_difference
0121 ///
0122 /// range-based version of the set_difference std algorithm
0123 ///
0124 /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
0125 /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
0126 /// \pre BinaryPredicate is a model of the BinaryPredicateConcept
0127 template<class SinglePassRange1, class SinglePassRange2,
0128          class OutputIterator>
0129 inline OutputIterator set_difference(const SinglePassRange1& rng1,
0130                                      const SinglePassRange2& rng2,
0131                                      OutputIterator out)
0132 {
0133     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0134     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
0135     return std::set_difference(boost::begin(rng1), boost::end(rng1),
0136                                boost::begin(rng2), boost::end(rng2), out);
0137 }
0138 
0139 /// \overload
0140 template<class SinglePassRange1, class SinglePassRange2,
0141          class OutputIterator, class BinaryPredicate>
0142 inline OutputIterator set_difference(const SinglePassRange1& rng1,
0143                                      const SinglePassRange2& rng2,
0144                                      OutputIterator          out,
0145                                      BinaryPredicate         pred)
0146 {
0147     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0148     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
0149     return std::set_difference(
0150         boost::begin(rng1), boost::end(rng1),
0151         boost::begin(rng2), boost::end(rng2), out, pred);
0152 }
0153 
0154 /// \brief template function set_symmetric_difference
0155 ///
0156 /// range-based version of the set_symmetric_difference std algorithm
0157 ///
0158 /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
0159 /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
0160 /// \pre BinaryPredicate is a model of the BinaryPredicateConcept
0161 template<class SinglePassRange1, class SinglePassRange2,
0162          class OutputIterator>
0163 inline OutputIterator
0164 set_symmetric_difference(const SinglePassRange1& rng1,
0165                          const SinglePassRange2& rng2,
0166                          OutputIterator          out)
0167 {
0168     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0169     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
0170     return std::set_symmetric_difference(boost::begin(rng1), boost::end(rng1),
0171                                          boost::begin(rng2), boost::end(rng2), out);
0172 }
0173 
0174 /// \overload
0175 template<class SinglePassRange1, class SinglePassRange2,
0176          class OutputIterator, class BinaryPredicate>
0177 inline OutputIterator
0178 set_symmetric_difference(const SinglePassRange1& rng1,
0179                          const SinglePassRange2& rng2,
0180                          OutputIterator          out,
0181                          BinaryPredicate         pred)
0182 {
0183     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0184     BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
0185     return std::set_symmetric_difference(
0186         boost::begin(rng1), boost::end(rng1),
0187         boost::begin(rng2), boost::end(rng2), out, pred);
0188 }
0189 
0190     } // namespace range
0191     using range::includes;
0192     using range::set_union;
0193     using range::set_intersection;
0194     using range::set_difference;
0195     using range::set_symmetric_difference;
0196 } // namespace boost
0197 
0198 #endif // include guard