00001 #ifndef NMWR_GB_SET_PRIMITIVES_H
00002 #define NMWR_GB_SET_PRIMITIVES_H
00003
00004
00005
00006
00007 #include "Container/set-traits.h"
00008
00018
00039
00040
00041
00042 template<class It, class S2>
00043 inline bool is_subset(It beg, It end, const S2& s2)
00044 {
00045 bool is_sub = true;
00046 while(is_sub && beg != end) {
00047
00048 is_sub = ( is_sub && s2.is_member(*beg));
00049 ++beg;
00050 }
00051 return is_sub;
00052 }
00053
00054
00055
00070
00071
00072 template<class It, class T>
00073 class is_element_of_pred {
00074 private:
00075 It begin;
00076 It end;
00077 public:
00078
00079 is_element_of_pred(It b, It e) : begin(b), end(e) {}
00080
00081 typedef T argument_type;
00082 typedef bool result_type;
00083
00086 bool operator()(const T& t) const {
00087 bool found = false;
00088 It i = begin;
00089 while( !found && (i != end)) {
00090 found = ((*i) == t);
00091 ++i;
00092 }
00093 return found;
00094 }
00095 };
00096
00101 template<class It,class T>
00102 inline is_element_of_pred<It,T>
00103 is_element_of(It b, It e, const T* )
00104 { return is_element_of_pred<It,T>(b,e);}
00105
00106
00111 template<class Cont>
00112 inline is_element_of_pred<typename Cont::const_iterator,
00113 typename Cont::value_type>
00114 is_element_of(const Cont& c)
00115 {
00116 typedef typename Cont::const_iterator it;
00117 typedef typename Cont::value_type val;
00118 return is_element_of_pred<it,val>(c.begin(),c.end());
00119 }
00120
00121 #endif
00122