PolyBoRi
PairManager.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
14 //*****************************************************************************
15 
16 #ifndef polybori_groebner_PairManager_h_
17 #define polybori_groebner_PairManager_h_
18 
19 #include "PairStatusSet.h"
20 
21 
22 // include basic definitions
23 #include "groebner_defs.h"
24 #include "pairs.h"
25 #include "PolyEntry.h"
26 #include "NextSpoly.h"
27 #include "CheckChainCriterion.h"
29 #include <utility>
30 
32 
37 class PairManager {
38  typedef PairManager self;
39 
40 public:
41  typedef std::priority_queue<Pair, std::vector<PairE>, PairECompare>
43 
44  PairManager(const BoolePolyRing& ring):
45  queue(ring) { }
46 
47  void appendHiddenGenerators(std::vector<Polynomial>& vec) {
48  queue_type temp(queue);
49  while(!temp.empty()){
50  appendTo(vec, temp.top());
51  temp.pop();
52  }
53  }
54 
55  void introducePair(const Pair& pair, bool isHFE) {
56  if (!skip(pair, isHFE)) queue.push(pair);
57  };
58 
60  if (PBORI_UNLIKELY(pairSetEmpty()))
61  return gen.leadingTerms.ring().zero();
62 
63  return NextSpoly(gen, status)(popped());
64  }
65 
66  bool pairSetEmpty() const { return queue.empty(); }
67 
68  template <class StrategyType>
69  void cleanTopByChainCriterion(StrategyType& strat) {
70  CheckChainCriterion<StrategyType> continuing(strat, status);
71  while(!pairSetEmpty() && continuing(queue.top()))
72  queue.pop();
73  }
74 
77 
78 protected:
81  Pair result = queue.top();
82  queue.pop();
83  return result;
84  }
85 
86 private:
87  bool skip(const Pair& pair, bool isHFE) {
88  return isHFE && (pair.getType() == IJ_PAIR) && (pair.sugar > 4);
89  };
91  void appendTo(std::vector<Polynomial>& vec, const Pair& current) const {
92  if (current.getType() == DELAYED_PAIR)
93  appendTo(vec, current.delayedPair().p);
94  }
95 
97  void appendTo(std::vector<Polynomial>& vec, const Polynomial& poly) const {
98  if (!poly.isZero())
99  vec.push_back(poly);
100  }
101 };
102 
104 
105 #endif /* polybori_groebner_PairManager_h_ */