PolyBoRi
|
00001 // -*- c++ -*- 00002 //***************************************************************************** 00014 //***************************************************************************** 00015 00016 #ifndef polybori_groebner_PolyEntryVector_h_ 00017 #define polybori_groebner_PolyEntryVector_h_ 00018 00019 #include "PolyEntryReference.h" 00020 #include "PolyEntryIndices.h" 00021 #include "PolyEntry.h" 00022 00023 // include basic definitions 00024 #include "groebner_defs.h" 00025 00026 BEGIN_NAMESPACE_PBORIGB 00027 00028 class PolyEntryVector { 00029 typedef std::vector<PolyEntry> data_type; 00030 00031 public: 00033 00034 typedef data_type::value_type value_type; 00035 typedef data_type::size_type size_type; 00036 typedef data_type::const_iterator const_iterator; 00037 typedef data_type::const_reference const_reference; 00038 typedef PolyEntryReference reference; 00039 00040 bool empty() const { return m_data.empty(); } 00041 size_type size() const { return m_data.size(); } 00042 const_iterator begin() const { return m_data.begin(); } 00043 const_iterator end() const { return m_data.end(); } 00044 const_reference front() const { return m_data.front(); } 00045 const_reference back() const { return m_data.back(); } 00046 00048 template <class KeyType> 00049 const_reference operator[](const KeyType& rhs) const { 00050 return operator()(rhs); 00051 } 00053 00055 reference first() { return reference(m_data.front(), m_indices); } 00056 00058 const_reference first() const { return front(); } 00059 00061 reference last() { return reference(m_data.back(), m_indices); } 00062 00064 const_reference last() const { return back(); } 00065 00067 PolyEntryVector(): 00068 m_data(), m_indices() {} 00069 00071 virtual void append(const PolyEntry& element) { 00072 m_data.push_back(element); 00073 00074 PBORI_ASSERT(m_indices.checked(back().lead) == (size_type)-1); 00075 m_indices.insert(back(), size() - 1); 00076 } 00077 00079 template <class KeyType> 00080 const_reference operator()(const KeyType& key) const { 00081 return m_data[index(key)]; 00082 } 00083 00085 template <class KeyType> 00086 reference operator()(const KeyType& rhs) { 00087 return reference(m_data[index(rhs)], m_indices); 00088 } 00089 00091 template <class KeyType, class Type> 00092 void exchange(const KeyType& key, const Type& rhs) { operator()(key) = rhs; } 00093 00095 template <class KeyType> 00096 size_type index(const KeyType& key) const { return m_indices(key); } 00097 00099 template <class KeyType> 00100 size_type checked_index(const KeyType& key) const { 00101 return m_indices.checked(key); 00102 } 00104 template <class KeyType> 00105 const Polynomial& polynomial(const KeyType& key) const { 00106 return operator[](key).p; 00107 } 00108 00109 private: 00110 data_type m_data; 00111 PolyEntryIndices m_indices; 00112 }; 00113 00114 END_NAMESPACE_PBORIGB 00115 00116 #endif /* polybori_groebner_PolyEntryVector_h_ */