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  PBORI_ASSERT(m_indices.checked(back().lead) == (size_type)-1);
75  m_indices.insert(back(), size() - 1);
76  }
77 
79  template <class KeyType>
80  const_reference operator()(const KeyType& key) const {
81  return m_data[index(key)];
82  }
83 
85  template <class KeyType>
86  reference operator()(const KeyType& rhs) {
87  return reference(m_data[index(rhs)], m_indices);
88  }
89 
91  template <class KeyType, class Type>
92  void exchange(const KeyType& key, const Type& rhs) { operator()(key) = rhs; }
93 
95  template <class KeyType>
96  size_type index(const KeyType& key) const { return m_indices(key); }
97 
99  template <class KeyType>
100  size_type checked_index(const KeyType& key) const {
101  return m_indices.checked(key);
102  }
104  template <class KeyType>
105  const Polynomial& polynomial(const KeyType& key) const {
106  return operator[](key).p;
107  }
108 
109 private:
110  data_type m_data;
111  PolyEntryIndices m_indices;
112 };
113 
115 
116 #endif /* polybori_groebner_PolyEntryVector_h_ */