Go to the documentation of this file.00001
00002
00003 #ifndef actasp_state_util_h__guard
00004 #define actasp_state_util_h__guard
00005
00006 #include <actasp/AspFluent.h>
00007
00008 #include <functional>
00009 #include <set>
00010
00011 namespace actasp {
00012
00013 template<typename FluentClass>
00014 struct StateComparator : public std::binary_function<const std::set<FluentClass>&,const std::set<FluentClass>&, bool> {
00015
00016 bool operator()(const std::set<FluentClass> &first,const std::set<FluentClass> &second) const {
00017
00018
00019 if (first.size() != second.size())
00020 return first.size() < second.size();
00021
00022
00023 typename std::set<FluentClass>::const_iterator thisV = first.begin();
00024 typename std::set<FluentClass>::const_iterator otherV = second.begin();
00025
00026 ActionComparator lessThen;
00027
00028 for (; thisV != first.end(); ++thisV, ++otherV) {
00029
00030 if (lessThen(*thisV , *otherV))
00031 return true;
00032 if (lessThen(*otherV , *thisV))
00033 return false;
00034 }
00035
00036
00037 return false;
00038
00039 }
00040
00041 };
00042
00043
00044
00045 }
00046
00047 #endif