PolyBoRi
PolyEntryVector.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
14 //*****************************************************************************
15 
16 #ifndef polybori_groebner_PolyEntryVector_h_
17 #define polybori_groebner_PolyEntryVector_h_
18 
19 #include "PolyEntryReference.h"
20 #include "PolyEntryIndices.h"
21 #include "PolyEntry.h"
22 
23 // include basic definitions
24 #include "groebner_defs.h"
25 
27 
29  typedef std::vector<PolyEntry> data_type;
30 
31 public:
33 
34  typedef data_type::value_type value_type;
35  typedef data_type::size_type size_type;
36  typedef data_type::const_iterator const_iterator;
37  typedef data_type::const_reference const_reference;
39 
40  bool empty() const { return m_data.empty(); }
41  size_type size() const { return m_data.size(); }
42  const_iterator begin() const { return m_data.begin(); }
43  const_iterator end() const { return m_data.end(); }
44  const_reference front() const { return m_data.front(); }
45  const_reference back() const { return m_data.back(); }
46 
48  template <class KeyType>
49  const_reference operator[](const KeyType& rhs) const {
50  return operator()(rhs);
51  }
53 
55  reference first() { return reference(m_data.front(), m_indices); }
56 
58  const_reference first() const { return front(); }
59 
61  reference last() { return reference(m_data.back(), m_indices); }
62 
64  const_reference last() const { return back(); }
65 
68  m_data(), m_indices() {}
69 
71  virtual void append(const PolyEntry& element) {
72  m_data.push_back(element);
73 
74 #ifndef PBORI_NDEBUG
75  if(m_indices.checked(back().lead) != (size_type)-1)
76  throw std::runtime_error("leading terms not unique when appending to PolyEntryVector");
77 #endif
78  m_indices.insert(back(), size() - 1);
79  }
80 
82  template <class KeyType>
83  const_reference operator()(const KeyType& key) const {
84  return m_data[index(key)];
85  }
86 
88  template <class KeyType>
89  reference operator()(const KeyType& rhs) {
90  return reference(m_data[index(rhs)], m_indices);
91  }
92 
94  template <class KeyType, class Type>
95  void exchange(const KeyType& key, const Type& rhs) { operator()(key) = rhs; }
96 
98  template <class KeyType>
99  size_type index(const KeyType& key) const { return m_indices(key); }
100 
102  template <class KeyType>
103  size_type checked_index(const KeyType& key) const {
104  return m_indices.checked(key);
105  }
107  template <class KeyType>
108  const Polynomial& polynomial(const KeyType& key) const {
109  return operator[](key).p;
110  }
111 
112 private:
113  data_type m_data;
114  PolyEntryIndices m_indices;
115 };
116 
118 
119 #endif /* polybori_groebner_PolyEntryVector_h_ */