00001 // -*- c++ -*- 00002 //***************************************************************************** 00013 //***************************************************************************** 00014 00015 #ifndef polybori_orderings_pbori_order_h_ 00016 #define polybori_orderings_pbori_order_h_ 00017 00018 // include basic definitions 00019 #include <polybori/pbori_defs.h> 00020 00021 // Get infrastructure for dynamic orderings 00022 #include "COrderingBase.h" 00023 00024 // get all available orderings 00025 #include <polybori/LexOrder.h> 00026 #include <polybori/DegLexOrder.h> 00027 #include <polybori/DegRevLexAscOrder.h> 00028 #include <polybori/BlockDegLexOrder.h> 00029 #include <polybori/BlockDegRevLexAscOrder.h> 00030 00031 BEGIN_NAMESPACE_PBORI 00032 00033 inline boost::shared_ptr<COrderingBase> 00034 get_ordering(CTypes::ordercode_type order) { 00035 typedef boost::shared_ptr<COrderingBase> order_ptr; 00036 00037 if(order == CTypes::lp) 00038 return order_ptr(new LexOrder); 00039 else if(order == CTypes::dlex) 00040 return order_ptr(new DegLexOrder); 00041 else if(order == CTypes::dp_asc) 00042 return order_ptr(new DegRevLexAscOrder); 00043 else if(order == CTypes::block_dlex) 00044 return order_ptr(new BlockDegLexOrder); 00045 else if(order == CTypes::block_dp_asc) 00046 return order_ptr(new BlockDegRevLexAscOrder); 00047 00048 // default is lex order 00049 return order_ptr(new LexOrder); 00050 } 00051 00052 00055 template <class LhsType, class RhsType, class BinaryPredicate> 00056 class lex_compare_predicate: 00057 public std::binary_function<LhsType, RhsType, bool> { 00058 public: 00059 00061 lex_compare_predicate(const BinaryPredicate& comp): 00062 m_comp(comp) {} 00063 00065 bool operator()(const LhsType& lhs, const RhsType& rhs) const { 00066 return std::lexicographical_compare(lhs.begin(), lhs.end(), 00067 rhs.begin(), rhs.end(), m_comp); 00068 } 00069 00070 private: 00071 BinaryPredicate m_comp; 00072 }; 00073 00074 END_NAMESPACE_PBORI 00075 00076 #endif