PPL  1.2
Parma_Polyhedra_Library::Linear_Expression::const_iterator Class Reference

#include <Linear_Expression_defs.hh>

Collaboration diagram for Parma_Polyhedra_Library::Linear_Expression::const_iterator:

Public Types

typedef std::bidirectional_iterator_tag iterator_category
 
typedef const Coefficient value_type
 
typedef std::ptrdiff_t difference_type
 
typedef value_typepointer
 
typedef Coefficient_traits::const_reference reference
 

Public Member Functions

 const_iterator ()
 Constructs an invalid const_iterator. More...
 
 const_iterator (const const_iterator &i)
 The copy constructor. More...
 
 ~const_iterator ()
 
void m_swap (const_iterator &i)
 Swaps i with *this. More...
 
const_iteratoroperator= (const const_iterator &i)
 Assigns i to *this . More...
 
const_iteratoroperator++ ()
 Navigates to the next nonzero coefficient. More...
 
const_iteratoroperator-- ()
 Navigates to the previous nonzero coefficient. More...
 
reference operator* () const
 Returns the current element. More...
 
Variable variable () const
 Returns the variable of the coefficient pointed to by *this. More...
 
bool operator== (const const_iterator &i) const
 Compares *this with i. More...
 
bool operator!= (const const_iterator &i) const
 Compares *this with i . More...
 

Private Member Functions

 const_iterator (Linear_Expression_Interface::const_iterator_interface *i)
 

Private Attributes

Linear_Expression_Interface::const_iterator_interfaceitr
 

Friends

class Linear_Expression
 

Related Functions

(Note that these are not member functions.)

void swap (Linear_Expression::const_iterator &x, Linear_Expression::const_iterator &y)
 Swaps x with y. More...
 
void swap (Linear_Expression::const_iterator &x, Linear_Expression::const_iterator &y)
 

Detailed Description

A const iterator on the expression (homogeneous) coefficient that are nonzero.

These iterators are invalidated by operations that modify the expression.

Definition at line 395 of file Linear_Expression_defs.hh.

Member Typedef Documentation

Definition at line 398 of file Linear_Expression_defs.hh.

typedef Coefficient_traits::const_reference Parma_Polyhedra_Library::Linear_Expression::const_iterator::reference

Definition at line 402 of file Linear_Expression_defs.hh.

Constructor & Destructor Documentation

Parma_Polyhedra_Library::Linear_Expression::const_iterator::const_iterator ( )
inlineexplicit

Constructs an invalid const_iterator.

This constructor takes $O(1)$ time.

Definition at line 623 of file Linear_Expression_inlines.hh.

624  : itr(NULL) {
625 }
Linear_Expression_Interface::const_iterator_interface * itr
Parma_Polyhedra_Library::Linear_Expression::const_iterator::const_iterator ( const const_iterator i)
inline

The copy constructor.

Parameters
iThe iterator that will be copied.

This constructor takes $O(1)$ time.

Definition at line 629 of file Linear_Expression_inlines.hh.

630  : itr(i.itr->clone()) {
631 }
Linear_Expression_Interface::const_iterator_interface * itr
Parma_Polyhedra_Library::Linear_Expression::const_iterator::~const_iterator ( )
inline

Definition at line 635 of file Linear_Expression_inlines.hh.

635  {
636  // Note that this does nothing if itr == NULL.
637  delete itr;
638 }
Linear_Expression_Interface::const_iterator_interface * itr
Parma_Polyhedra_Library::Linear_Expression::const_iterator::const_iterator ( Linear_Expression_Interface::const_iterator_interface i)
inlineprivate

Constructor from a const_iterator_interface*. The new object takes ownership of the dynamic object.

Definition at line 701 of file Linear_Expression_inlines.hh.

702  : itr(i) {
703  PPL_ASSERT(i != NULL);
704 }
Linear_Expression_Interface::const_iterator_interface * itr

Member Function Documentation

void Parma_Polyhedra_Library::Linear_Expression::const_iterator::m_swap ( const_iterator i)
inline

Swaps i with *this.

Parameters
iThe iterator that will be swapped with *this.

This method takes $O(1)$ time.

Definition at line 641 of file Linear_Expression_inlines.hh.

References itr, Parma_Polyhedra_Library::swap(), and Parma_Polyhedra_Library::Linear_Expression::swap().

Referenced by swap().

641  {
642  using std::swap;
643  swap(itr, i.itr);
644 }
void swap(CO_Tree &x, CO_Tree &y)
Linear_Expression_Interface::const_iterator_interface * itr
void swap(Linear_Expression::const_iterator &x, Linear_Expression::const_iterator &y)
Swaps x with y.
bool Parma_Polyhedra_Library::Linear_Expression::const_iterator::operator!= ( const const_iterator i) const
inline

Compares *this with i .

Parameters
iThe iterator that will be compared with *this.

Definition at line 695 of file Linear_Expression_inlines.hh.

695  {
696  return !(*this == i);
697 }
Linear_Expression::const_iterator::reference Parma_Polyhedra_Library::Linear_Expression::const_iterator::operator* ( ) const
inline

Returns the current element.

Definition at line 673 of file Linear_Expression_inlines.hh.

673  {
674  PPL_ASSERT(itr != NULL);
675  return *(*itr);
676 }
Linear_Expression_Interface::const_iterator_interface * itr
Linear_Expression::const_iterator & Parma_Polyhedra_Library::Linear_Expression::const_iterator::operator++ ( )
inline

Navigates to the next nonzero coefficient.

This method takes $O(n)$ time for dense expressions, and $O(1)$ time for sparse expressions.

Definition at line 657 of file Linear_Expression_inlines.hh.

657  {
658  PPL_ASSERT(itr != NULL);
659  ++(*itr);
660  return *this;
661 }
Linear_Expression_Interface::const_iterator_interface * itr
Linear_Expression::const_iterator & Parma_Polyhedra_Library::Linear_Expression::const_iterator::operator-- ( )
inline

Navigates to the previous nonzero coefficient.

This method takes $O(n)$ time for dense expressions, and $O(1)$ time for sparse expressions.

Definition at line 665 of file Linear_Expression_inlines.hh.

665  {
666  PPL_ASSERT(itr != NULL);
667  --(*itr);
668  return *this;
669 }
Linear_Expression_Interface::const_iterator_interface * itr
Linear_Expression::const_iterator & Parma_Polyhedra_Library::Linear_Expression::const_iterator::operator= ( const const_iterator i)
inline

Assigns i to *this .

Parameters
iThe iterator that will be assigned into *this.

This method takes $O(1)$ time.

Definition at line 648 of file Linear_Expression_inlines.hh.

References Parma_Polyhedra_Library::swap(), and Parma_Polyhedra_Library::Linear_Expression::swap().

648  {
649  const_iterator tmp = i;
650  using std::swap;
651  swap(*this, tmp);
652  return *this;
653 }
void swap(CO_Tree &x, CO_Tree &y)
void swap(Linear_Expression::const_iterator &x, Linear_Expression::const_iterator &y)
Swaps x with y.
bool Parma_Polyhedra_Library::Linear_Expression::const_iterator::operator== ( const const_iterator i) const
inline

Compares *this with i.

Parameters
iThe iterator that will be compared with *this.

Definition at line 687 of file Linear_Expression_inlines.hh.

References itr.

687  {
688  PPL_ASSERT(itr != NULL);
689  PPL_ASSERT(i.itr != NULL);
690  return *itr == *(i.itr);
691 }
Linear_Expression_Interface::const_iterator_interface * itr
Variable Parma_Polyhedra_Library::Linear_Expression::const_iterator::variable ( ) const
inline

Returns the variable of the coefficient pointed to by *this.

Returns
the variable of the coefficient pointed to by *this.

Definition at line 680 of file Linear_Expression_inlines.hh.

Referenced by Parma_Polyhedra_Library::Polyhedron::modify_according_to_evolution().

680  {
681  PPL_ASSERT(itr != NULL);
682  return itr->variable();
683 }
Linear_Expression_Interface::const_iterator_interface * itr
virtual Variable variable() const =0
Returns the variable of the coefficient pointed to by *this.

Friends And Related Function Documentation

friend class Linear_Expression
friend

Definition at line 483 of file Linear_Expression_defs.hh.

Definition at line 837 of file Linear_Expression_inlines.hh.

References m_swap().

838  {
839  x.m_swap(y);
840 }

Swaps x with y.

Member Data Documentation

Linear_Expression_Interface::const_iterator_interface* Parma_Polyhedra_Library::Linear_Expression::const_iterator::itr
private

Definition at line 481 of file Linear_Expression_defs.hh.

Referenced by m_swap(), and operator==().


The documentation for this class was generated from the following files: