+++ /dev/null
-# CHECK_FOR_IS_SORTED
-# -------------------
-# Look for is_sorted in std:: and __gnu_cxx:: and define
-# some things to make it easy to find later.
-AC_DEFUN([CHECK_FOR_IS_SORTED], [
-AC_MSG_CHECKING([where we can find is_sorted])
-AC_LANG_PUSH([C++])
-is_sorted_result=
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <algorithm>],
- [std::is_sorted((int*)0L, (int*)0L);])],
- [is_sorted_result=std],
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <ext/algorithm>],
- [__gnu_cxx::is_sorted((int*)0L, (int*)0L);])],
- [is_sorted_result=__gnu_cxx],
- [AC_MSG_FAILURE([cannot find std::is_sorted() or __gnu_cxx::is_sorted()])])])
-AC_LANG_POP([C++])
-AC_MSG_RESULT($is_sorted_result)
-if test "$is_sorted_result" = __gnu_cxx; then is_sorted_result=1; else is_sorted_result=0; fi
-AC_DEFINE_UNQUOTED([IS_SORTED_IN_GNUCXX_NAMESPACE], $is_sorted_result, [Define to 1 if __gnu_cxx::is_sorted() exists])
-])# CHECK_FOR_IS_SORTED
bool VarList::isSorted(iterator start, iterator end) {
-#if IS_SORTED_IN_GNUCXX_NAMESPACE
- return __gnu_cxx::is_sorted(start, end);
-#else /* IS_SORTED_IN_GNUCXX_NAMESPACE */
return std::is_sorted(start, end);
-#endif /* IS_SORTED_IN_GNUCXX_NAMESPACE */
}
bool VarList::isMember(Node n) {
otherEnd = other.internalEnd();
Variable::VariableNodeCmp cmp;
-
- merge_ranges(thisBegin, thisEnd, otherBegin, otherEnd, result, cmp);
+ std::merge(thisBegin, thisEnd, otherBegin, otherEnd, std::back_inserter(result), cmp);
Assert(result.size() >= 2);
Node mult = NodeManager::currentNM()->mkNode(kind::NONLINEAR_MULT, result);
Polynomial Polynomial::operator+(const Polynomial& vl) const {
std::vector<Monomial> sortedMonos;
- merge_ranges(begin(), end(), vl.begin(), vl.end(), sortedMonos);
+ std::merge(begin(), end(), vl.begin(), vl.end(), std::back_inserter(sortedMonos));
Monomial::combineAdjacentMonomials(sortedMonos);
//std::vector<Monomial> combined = Monomial::sumLikeTerms(sortedMonos);
#include <algorithm>
#include <list>
-#if IS_SORTED_IN_GNUCXX_NAMESPACE
-# include <ext/algorithm>
-#endif /* IS_SORTED_IN_GNUCXX_NAMESPACE */
-
#include "base/output.h"
#include "expr/node.h"
#include "expr/node_self_iterator.h"
}
struct VariableNodeCmp {
- static inline int cmp(Node n, Node m) {
+ static inline int cmp(const Node& n, const Node& m) {
if ( n == m ) { return 0; }
// this is now slightly off of the old variable order.
}
}
- bool operator()(Node n, Node m) const {
+ bool operator()(const Node& n, const Node& m) const {
return VariableNodeCmp::cmp(n,m) < 0;
}
};
return Node(nb);
}/* makeNode<GetNodeIterator>(Kind, iterator, iterator) */
-
-template <class GetNodeIterator, class T>
-static void copy_range(GetNodeIterator begin, GetNodeIterator end, std::vector<T>& result){
- while(begin != end){
- result.push_back(*begin);
- ++begin;
- }
-}
-
-template <class GetNodeIterator, class T>
-static void merge_ranges(GetNodeIterator first1,
- GetNodeIterator last1,
- GetNodeIterator first2,
- GetNodeIterator last2,
- std::vector<T>& result) {
-
- while(first1 != last1 && first2 != last2){
- if( (*first1) < (*first2) ){
- result.push_back(*first1);
- ++ first1;
- }else{
- result.push_back(*first2);
- ++ first2;
- }
- }
- copy_range(first1, last1, result);
- copy_range(first2, last2, result);
-}
-
-template <class GetNodeIterator, class T, class Cmp>
-static void merge_ranges(GetNodeIterator first1,
- GetNodeIterator last1,
- GetNodeIterator first2,
- GetNodeIterator last2,
- std::vector<T>& result,
- const Cmp& cmp) {
-
- while(first1 != last1 && first2 != last2){
- if( cmp(*first1, *first2) ){
- result.push_back(*first1);
- ++ first1;
- }else{
- result.push_back(*first2);
- ++ first2;
- }
- }
- copy_range(first1, last1, result);
- copy_range(first2, last2, result);
-}
-
/**
* A VarList is a sorted list of variables representing a product.
* If the VarList is empty, it represents an empty product or 1.
}
static bool isSorted(const std::vector<Monomial>& m) {
-#if IS_SORTED_IN_GNUCXX_NAMESPACE
- return __gnu_cxx::is_sorted(m.begin(), m.end());
-#else /* IS_SORTED_IN_GNUCXX_NAMESPACE */
return std::is_sorted(m.begin(), m.end());
-#endif /* IS_SORTED_IN_GNUCXX_NAMESPACE */
}
static bool isStrictlySorted(const std::vector<Monomial>& m) {
public:
static bool isMember(TNode n);
- class iterator {
+ class iterator : public std::iterator<std::input_iterator_tag, Monomial> {
private:
internal_iterator d_iter;
iterator tailStart = begin();
++tailStart;
std::vector<Monomial> subrange;
- copy_range(tailStart, end(), subrange);
+ std::copy(tailStart, end(), std::back_inserter(subrange));
return mkPolynomial(subrange);
}