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_UNI_HH
00027 # define MLN_SET_UNI_HH
00028 
00032 
00033 # include <algorithm>
00034 # include <iterator>
00035 
00036 # include <mln/core/site_set/p_set.hh>
00037 # include <mln/convert/from_to.hh>
00038 # include <mln/util/ord.hh>
00039 
00040 
00041 namespace mln
00042 {
00043 
00044   namespace set
00045   {
00046 
00051     template <typename Sl, typename Sr>
00052     p_set<mln_site(Sl)>
00053     uni(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs);
00054 
00055 
00056 # ifndef MLN_INCLUDE_ONLY
00057 
00058     template <typename Sl, typename Sr>
00059     inline
00060     p_set<mln_site(Sl)>
00061     uni(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs)
00062     {
00063       trace::entering("set::uni");
00064 
00065       typedef mln_site(Sl) P;
00066       mlc_converts_to(mln_psite(Sr), P)::check(); 
00067       std::set< P, util::ord<P> > sl, sr, su;
00068       convert::from_to(lhs, sl);
00069       convert::from_to(rhs, sr);
00070       std::set_union(sl.begin(), sl.end(),
00071                      sr.begin(), sr.end(),
00072                      std::inserter(su, su.begin()),
00073                      util::ord<P>());
00074       p_set<P> s;
00075       convert::from_to(su, s);
00076 
00077       trace::exiting("set::uni");
00078       return s;
00079     }
00080 
00081 # endif // ! MLN_INCLUDE_ONLY
00082 
00083   } 
00084 
00085 } 
00086 
00087 
00088 #endif // ! MLN_SET_UNI_HH