00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MLN_SET_DIFF_HH
00027 # define MLN_SET_DIFF_HH
00028
00035
00036 # include <algorithm>
00037 # include <iterator>
00038
00039 # include <mln/core/site_set/p_set.hh>
00040 # include <mln/convert/from_to.hh>
00041 # include <mln/util/ord.hh>
00042
00043
00044
00045 namespace mln
00046 {
00047
00048 namespace set
00049 {
00050
00055 template <typename Sl, typename Sr>
00056 p_set<mln_site(Sl)>
00057 diff(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs);
00058
00059
00060
00061 # ifndef MLN_INCLUDE_ONLY
00062
00063 template <typename Sl, typename Sr>
00064 inline
00065 p_set<mln_site(Sl)>
00066 diff(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs)
00067 {
00068 trace::entering("set::diff");
00069
00070 typedef mln_site(Sl) P;
00071 mlc_converts_to(mln_psite(Sr), P)::check();
00072 std::set< P, util::ord<P> > sl, sr, sd;
00073 convert::from_to(lhs, sl);
00074 convert::from_to(rhs, sr);
00075 std::set_difference(sl.begin(), sl.end(),
00076 sr.begin(), sr.end(),
00077 std::inserter(sd, sd.begin()),
00078 util::ord<P>());
00079 p_set<P> s;
00080 convert::from_to(sd, s);
00081
00082 trace::exiting("set::diff");
00083 return s;
00084 }
00085
00086 # endif // ! MLN_INCLUDE_ONLY
00087
00088 }
00089
00090 }
00091
00092
00093 #endif // ! MLN_SET_DIFF_HH