// (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_DIFFERENCE_HPP #define BOOST_SETS_ORDERED_SET_DIFFERENCE_HPP namespace boost { namespace sets { // Compute the set difference for standard sets. template inline void difference(const std::set& s, const std::set& t, std::set& result) { std::set_difference(s.begin(), s.end(), t.begin(), t.end(), std::inserter(result, result.begin())); } // Return the difference of two sets (i.e., the sets in a, but not in b). template inline std::set difference(const std::set& s, const std::set& t) { std::set result; difference(s, t, result); return result; } // Remove from set s the elements that appear in set t. template inline void difference_inplace(std::set& s, const std::set& t) { s = difference(s, t); } // Compute the symmetric difference for standard sets. The symmetric // difference of s and t is all elements in either s or t, but not both. template inline void symmetric_difference(const std::set& s, const std::set& t, std::set& result) { std::set_symmetric_difference(s.begin(), s.end(), t.begin(), t.end(), std::inserter(result, result.begin())); } // Return the difference of two sets (i.e., the sets in a, but not in b). template inline std::set symmetric_difference(const std::set& s, const std::set& t) { std::set result; symmetric_difference(s, t, result); return result; } // Modify s so that it includes elements in either s or t, but not s. This // is a somewhat strange operation to do in-place. Really strange, but // I'll allow it. template inline void symmetric_difference_inplace(std::set& s, const std::set& t) { s = symmetric_difference(s, t); } } /* namespace sets */ } /* namespace boost */ #endif