pbori_order.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_orderings_pbori_order_h_
#define polybori_orderings_pbori_order_h_
// include basic definitions
#include <polybori/pbori_defs.h>
// Get infrastructure for dynamic orderings
#include "COrderingBase.h"
// get all available orderings
#include <polybori/LexOrder.h>
#include <polybori/DegLexOrder.h>
#include <polybori/DegRevLexAscOrder.h>
#include <polybori/BlockDegLexOrder.h>
#include <polybori/BlockDegRevLexAscOrder.h>
BEGIN_NAMESPACE_PBORI
inline boost::shared_ptr<COrderingBase>
get_ordering(CTypes::ordercode_type order) {
typedef boost::shared_ptr<COrderingBase> order_ptr;
if(order == CTypes::lp)
return order_ptr(new LexOrder);
else if(order == CTypes::dlex)
return order_ptr(new DegLexOrder);
else if(order == CTypes::dp_asc)
return order_ptr(new DegRevLexAscOrder);
else if(order == CTypes::block_dlex)
return order_ptr(new BlockDegLexOrder);
else if(order == CTypes::block_dp_asc)
return order_ptr(new BlockDegRevLexAscOrder);
// default is lex order
return order_ptr(new LexOrder);
}
template <class LhsType, class RhsType, class BinaryPredicate>
class lex_compare_predicate:
public std::binary_function<LhsType, RhsType, bool> {
public:
lex_compare_predicate(const BinaryPredicate& comp):
m_comp(comp) {}
bool operator()(const LhsType& lhs, const RhsType& rhs) const {
return std::lexicographical_compare(lhs.begin(), lhs.end(),
rhs.begin(), rhs.end(), m_comp);
}
private:
BinaryPredicate m_comp;
};
END_NAMESPACE_PBORI
#endif