PolyEntryVector.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_groebner_PolyEntryVector_h_
#define polybori_groebner_PolyEntryVector_h_
#include "PolyEntryReference.h"
#include "PolyEntryIndices.h"
#include "PolyEntry.h"
// include basic definitions
#include "groebner_defs.h"
BEGIN_NAMESPACE_PBORIGB
class PolyEntryVector {
typedef std::vector<PolyEntry> data_type;
public:
typedef data_type::value_type value_type;
typedef data_type::size_type size_type;
typedef data_type::const_iterator const_iterator;
typedef data_type::const_reference const_reference;
typedef PolyEntryReference reference;
bool empty() const { return m_data.empty(); }
size_type size() const { return m_data.size(); }
const_iterator begin() const { return m_data.begin(); }
const_iterator end() const { return m_data.end(); }
const_reference front() const { return m_data.front(); }
const_reference back() const { return m_data.back(); }
template <class KeyType>
const_reference operator[](const KeyType& rhs) const {
return operator()(rhs);
}
reference first() { return reference(m_data.front(), m_indices); }
const_reference first() const { return front(); }
reference last() { return reference(m_data.back(), m_indices); }
const_reference last() const { return back(); }
PolyEntryVector():
m_data(), m_indices() {}
virtual void append(const PolyEntry& element) {
m_data.push_back(element);
#ifndef PBORI_NDEBUG
if(m_indices.checked(back().lead) != (size_type)-1)
throw std::runtime_error("leading terms not unique when appending to PolyEntryVector");
#endif
m_indices.insert(back(), size() - 1);
}
template <class KeyType>
const_reference operator()(const KeyType& key) const {
return m_data[index(key)];
}
template <class KeyType>
reference operator()(const KeyType& rhs) {
return reference(m_data[index(rhs)], m_indices);
}
template <class KeyType, class Type>
void exchange(const KeyType& key, const Type& rhs) { operator()(key) = rhs; }
template <class KeyType>
size_type index(const KeyType& key) const { return m_indices(key); }
template <class KeyType>
size_type checked_index(const KeyType& key) const {
return m_indices.checked(key);
}
template <class KeyType>
const Polynomial& polynomial(const KeyType& key) const {
return operator[](key).p;
}
private:
data_type m_data;
PolyEntryIndices m_indices;
};
END_NAMESPACE_PBORIGB
#endif /* polybori_groebner_PolyEntryVector_h_ */
polybori::groebner::PolyEntryVector::end
const_iterator end() const
Definition: PolyEntryVector.h:43
polybori::groebner::PolyEntryVector::first
const_reference first() const
Constant variant, equivalent to front, for completeness reasons.
Definition: PolyEntryVector.h:58
polybori::groebner::PolyEntryVector
Definition: PolyEntryVector.h:28
polybori::groebner::PolyEntryVector::size_type
data_type::size_type size_type
Definition: PolyEntryVector.h:35
PolyEntryIndices.h
polybori::groebner::PolyEntryVector::index
size_type index(const KeyType &key) const
Retrieve index associated to key.
Definition: PolyEntryVector.h:99
polybori::groebner::PolyEntryVector::const_reference
data_type::const_reference const_reference
Definition: PolyEntryVector.h:37
polybori::groebner::PolyEntryVector::first
reference first()
Alternative to front which allows partial (but consistent) access.
Definition: PolyEntryVector.h:55
END_NAMESPACE_PBORIGB
#define END_NAMESPACE_PBORIGB
Definition: groebner_defs.h:16
PolyEntry.h
polybori::groebner::PolyEntryVector::PolyEntryVector
PolyEntryVector()
Default constructor.
Definition: PolyEntryVector.h:67
BEGIN_NAMESPACE_PBORIGB
#define BEGIN_NAMESPACE_PBORIGB
Definition: groebner_defs.h:15
polybori::groebner::PolyEntry
This class defines PolyEntry.
Definition: PolyEntry.h:32
polybori::groebner::PolyEntryVector::begin
const_iterator begin() const
Definition: PolyEntryVector.h:42
polybori::groebner::PolyEntryVector::operator()
const_reference operator()(const KeyType &key) const
Read-only access to element by index, leading term or monomial.
Definition: PolyEntryVector.h:83
polybori::BoolePolynomial
This class wraps the underlying decicion diagram type and defines the necessary operations.
Definition: BoolePolynomial.h:85
polybori::groebner::PolyEntryVector::polynomial
const Polynomial & polynomial(const KeyType &key) const
Retrieve polynomial associated to key.
Definition: PolyEntryVector.h:108
groebner_defs.h
polybori::groebner::PolyEntryVector::last
const_reference last() const
Constant variant, equivalent to back, for completeness reasons.
Definition: PolyEntryVector.h:64
polybori::groebner::PolyEntryVector::back
const_reference back() const
Definition: PolyEntryVector.h:45
polybori::groebner::PolyEntryIndices
This class defines PolyEntryIndices.
Definition: PolyEntryIndices.h:33
PolyEntryReference.h
polybori::groebner::PolyEntryVector::append
virtual void append(const PolyEntry &element)
Just insert element.
Definition: PolyEntryVector.h:71
polybori::groebner::PolyEntryVector::exchange
void exchange(const KeyType &key, const Type &rhs)
Exchange element given by key.
Definition: PolyEntryVector.h:95
polybori::groebner::PolyEntryVector::operator()
reference operator()(const KeyType &rhs)
(Partially) write access to element by index, leading term or monomial
Definition: PolyEntryVector.h:89
polybori::groebner::PolyEntryVector::size
size_type size() const
Definition: PolyEntryVector.h:41
polybori::groebner::PolyEntryVector::const_iterator
data_type::const_iterator const_iterator
Definition: PolyEntryVector.h:36
polybori::groebner::PolyEntryVector::value_type
data_type::value_type value_type
Vector-style interface.
Definition: PolyEntryVector.h:34
polybori::groebner::PolyEntryVector::last
reference last()
Alternative to back() which allows partial (but consistent) access.
Definition: PolyEntryVector.h:61
polybori::groebner::PolyEntryVector::operator[]
const_reference operator[](const KeyType &rhs) const
Read-only access to element by index, leading term or monomial.
Definition: PolyEntryVector.h:49
polybori::groebner::PolyEntryReference
This class defines PolyEntryReference.
Definition: PolyEntryReference.h:34
polybori::groebner::PolyEntryVector::empty
bool empty() const
Definition: PolyEntryVector.h:40
polybori::groebner::PolyEntryVector::reference
PolyEntryReference reference
Definition: PolyEntryVector.h:38
polybori::groebner::PolyEntryVector::front
const_reference front() const
Definition: PolyEntryVector.h:44
polybori::groebner::PolyEntryVector::checked_index
size_type checked_index(const KeyType &key) const
Retrieve index associated to key if key exists, -1 otherwise.
Definition: PolyEntryVector.h:103