PolyBoRi
pbori_order.h
Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //*****************************************************************************
00013 //*****************************************************************************
00014 
00015 // include basic definitions
00016 #include "pbori_defs.h"
00017 
00018 #ifndef pbori_order_h_
00019 #define pbori_order_h_
00020 
00021 // Get infrastructure for dynamic orderings
00022 #include "COrderingBase.h"
00023 
00024 // get all available orderings
00025 #include "LexOrder.h"
00026 #include "DegLexOrder.h"
00027 #include "DegRevLexAscOrder.h"
00028 #include "BlockDegLexOrder.h"
00029 #include "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