carl  24.04
Computer ARithmetic Library
CriticalPairsEntry.h
Go to the documentation of this file.
1 
2 
3 
4 /**
5  * @file CriticalPairsEntry.h
6  * @ingroup gb
7  * @author Sebastian Junges
8  */
9 #pragma once
10 
12 #include "SPolPair.h"
13 
14 #include <list>
15 
16 namespace carl
17 {
18 
19 /**
20  * A list of SPol pairs which have to be checked by the Buchberger algorithm.
21  * We keep the list sorted according the compare ordering on SPol Pairs.
22  * @ingroup gb
23  */
24 template<class Compare>
26 {
27 public:
28 
29  /**
30  * Saves the list of pairs and sorts them according the configured ordering.
31  * @param pairs
32  */
33  explicit CriticalPairsEntry(std::list<SPolPair>&& pairs) : mPairs(std::move(pairs))
34  {
36  }
37 
38  /**
39  * Get the LCM of the first element.
40  * @return
41  */
43  {
44  return mPairs.front().mLcm;
45  }
46 
47  /**
48  * Get the front of the list.
49  * @return
50  */
51  const SPolPair& getFirst() const {
52  return mPairs.front();
53  }
54 
55  /**
56  * Removes the first element.
57  * @return empty()
58  */
59  bool update() {
60  mPairs.pop_front();
61  return mPairs.empty();
62  }
63 
64  /**
65  * The const iterator to the begin
66  * @return begin of list
67  */
68  std::list<SPolPair>::const_iterator getPairsBegin() const noexcept {
69  return mPairs.begin();
70  }
71 
72  /**
73  * The const iterator to the end()
74  * @return end of list
75  */
76  std::list<SPolPair>::const_iterator getPairsEnd() const noexcept {
77  return mPairs.end();
78  }
79 
80  /**
81  * The iterator to the end()
82  * @return begin of list
83  */
84  std::list<SPolPair>::iterator getPairsBegin() noexcept {
85  return mPairs.begin();
86  }
87 
88  /**
89  * The iterator to the end()
90  * @return end of list
91  */
92  std::list<SPolPair>::iterator getPairsEnd() noexcept {
93  return mPairs.end();
94  }
95 
96  /**
97  * Removes the element at the iterator.
98  * @param it The iterator to the element to be erased.
99  * @return The next element.
100  */
101  std::list<SPolPair>::iterator erase(std::list<SPolPair>::iterator it) {
102  return mPairs.erase(it);
103  }
104 
105  void print( std::ostream& os = std::cout )
106  {
107  for (const auto& p: mPairs) {
108  p.print(os);
109  }
110  }
111 private:
112  std::list<SPolPair> mPairs;
113 };
114 }
carl is the main namespace for the library.
A list of SPol pairs which have to be checked by the Buchberger algorithm.
std::list< SPolPair >::iterator erase(std::list< SPolPair >::iterator it)
Removes the element at the iterator.
bool update()
Removes the first element.
std::list< SPolPair > mPairs
std::list< SPolPair >::const_iterator getPairsBegin() const noexcept
The const iterator to the begin.
void print(std::ostream &os=std::cout)
std::list< SPolPair >::const_iterator getPairsEnd() const noexcept
The const iterator to the end()
std::list< SPolPair >::iterator getPairsBegin() noexcept
The iterator to the end()
CriticalPairsEntry(std::list< SPolPair > &&pairs)
Saves the list of pairs and sorts them according the configured ordering.
std::list< SPolPair >::iterator getPairsEnd() noexcept
The iterator to the end()
const SPolPair & getFirst() const
Get the front of the list.
const Monomial::Arg & getSortedFirstLCM() const
Get the LCM of the first element.
Basic spol-pair.
Definition: SPolPair.h:20
std::shared_ptr< const Monomial > Arg
Definition: Monomial.h:62