PolyBoRi
RankingVector.h
Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //*****************************************************************************
00014 //*****************************************************************************
00015 
00016 #ifndef polybori_groebner_RankingVector_h_
00017 #define polybori_groebner_RankingVector_h_
00018 
00019 // include basic definitions
00020 #include "groebner_defs.h"
00021 
00022 #include <vector>
00023 
00024 BEGIN_NAMESPACE_PBORIGB
00025 
00030 class RankingVector:
00031   public std::vector<int> {
00032   typedef std::vector<value_type> base; 
00033 
00034 public:
00035   RankingVector(size_type len): base(len, 0) {}
00036 
00037   void increment(size_type idx) {  ++operator[](idx); }
00038 
00039   void rerank(const Exponent& exp) {
00040     if (exp.deg() >= 2)
00041       for_each(exp.begin(), exp.end(), *this, &RankingVector::increment);
00042   }
00043 
00044   value_type max_index() const {
00045     return (empty()? -1: std::max_element(begin(), end()) - begin());
00046   }
00047 
00048 };
00049 
00050 
00051 END_NAMESPACE_PBORIGB
00052 
00053 #endif /* polybori_groebner_RankingVector_h_ */