// (C) Copyright 2008-2009 SDML (www.sdml.info) // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // Copyright Andrew Sutton 2007 // // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_SETS_ORDERED_SET_INTERSECTION_HPP #define BOOST_SETS_ORDERED_SET_INTERSECTION_HPP namespace boost { namespace sets { // Compute the intersection of a and b and store it in result. template inline void intersection(const std::set& s, const std::set& t, std::set& result) { std::set_intersection(s.begin(), s.end(), t.begin(), t.end(), std::inserter(result, result.begin())); } // Return the intersection of a and b. template inline std::set intersection(const std::set& s, const std::set& t) { std::set result; intersection(s, t, result); return result; } // Remove from set a all elements that are not in both a and b. If the // intersection is represented by the & operator, this would be akin to // writing a &= b. Note that this doesn't really compute the intersection // in place, but simply computes the intersection and swaps the result with // the set a (so it just looks like it's in place). template inline void intersection_inplace(std::set& s, const std::set& t) { s = intersection(s, t); } } /* namespace sets */ } /* namespace boost */ #endif