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
00027
00028
00029
00030
00031
00032
00033 #ifndef SETWISESTABILIZERPREDICATE_H_
00034 #define SETWISESTABILIZERPREDICATE_H_
00035
00036 #include "subgroup_predicate.h"
00037 #include "search/partition/set_stabilize_refinement.h"
00038 #include "search/partition/refinement_family.h"
00039
00040 #include <boost/foreach.hpp>
00041
00042 namespace permlib {
00043
00045 template <class PERM>
00046 class SetwiseStabilizerPredicate : public SubgroupPredicate<PERM> {
00047 public:
00049
00053 template<class InputIterator>
00054 SetwiseStabilizerPredicate(InputIterator begin, InputIterator end);
00055
00056 virtual bool operator()(const PERM &p) const;
00057 virtual bool childRestriction(const PERM &h, uint i, ulong beta_i) const;
00058 virtual uint limit() const;
00059 private:
00060
00061 std::vector<ulong> m_delta;
00062 };
00063
00064
00065
00066
00067
00068 template <class PERM>
00069 template <class InputIterator>
00070 SetwiseStabilizerPredicate<PERM>::SetwiseStabilizerPredicate(InputIterator begin, InputIterator end)
00071 : m_delta(begin, end)
00072 { }
00073
00074 template <class PERM>
00075 bool SetwiseStabilizerPredicate<PERM>::operator()(const PERM &p) const {
00076 BOOST_FOREACH(ulong delta_i, m_delta) {
00077 if (std::find(m_delta.begin(), m_delta.end(), p / delta_i) == m_delta.end())
00078 return false;
00079 }
00080 return true;
00081 }
00082
00083 template <class PERM>
00084 bool SetwiseStabilizerPredicate<PERM>::childRestriction(const PERM &h, uint i, ulong beta_i) const {
00085 if (std::find(m_delta.begin(), m_delta.end(), h / beta_i) == m_delta.end())
00086 return false;
00087 return true;
00088 }
00089
00090 template <class PERM>
00091 uint SetwiseStabilizerPredicate<PERM>::limit() const {
00092 return m_delta.size();
00093 }
00094
00095 }
00096
00097 #endif // -- SETWISESTABILIZERPREDICATE_H_