Parma_Polyhedra_Library::Variables_Set Class Reference

An std::set of variables' indexes. More...

#include <Variables_Set.defs.hh>

List of all members.

Public Member Functions

 Variables_Set ()
 Builds the empty set of variable indexes.
 Variables_Set (const Variable &v)
 Builds the singleton set of indexes containing v.id();.
 Variables_Set (const Variable &v, const Variable &w)
 Builds the set of variables's indexes in the range from v.id() to w.id().
dimension_type space_dimension () const
 Returns the dimension of the smallest vector space enclosing all the variables whose indexes are in the set.
void insert (Variable v)
 Inserts the index of variable v into the set.
bool ascii_load (std::istream &s)
 Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise.
memory_size_type total_memory_in_bytes () const
 Returns the total size in bytes of the memory occupied by *this.
memory_size_type external_memory_in_bytes () const
 Returns the size in bytes of the memory managed by *this.
bool OK () const
 Checks if all the invariants are satisfied.
void ascii_dump () const
 Writes to std::cerr an ASCII representation of *this.
void ascii_dump (std::ostream &s) const
 Writes to s an ASCII representation of *this.
void print () const
 Prints *this to std::cerr using operator<<.

Static Public Member Functions

static dimension_type max_space_dimension ()
 Returns the maximum space dimension a Variables_Set can handle.

Private Types

typedef std::set< dimension_typeBase

Related Functions

(Note that these are not member functions.)



std::ostream & operator<< (std::ostream &s, const Variables_Set &v)
 Output operator.

Detailed Description

An std::set of variables' indexes.

Definition at line 47 of file Variables_Set.defs.hh.


Member Typedef Documentation

Definition at line 50 of file Variables_Set.defs.hh.


Constructor & Destructor Documentation

Parma_Polyhedra_Library::Variables_Set::Variables_Set (  )  [inline]

Builds the empty set of variable indexes.

Definition at line 33 of file Variables_Set.inlines.hh.

00034   : Base() {
00035 }

Parma_Polyhedra_Library::Variables_Set::Variables_Set ( const Variable v  )  [inline, explicit]

Builds the singleton set of indexes containing v.id();.

Definition at line 43 of file Variables_Set.inlines.hh.

References insert().

00044   : Base() {
00045   insert(v);
00046 }

Parma_Polyhedra_Library::Variables_Set::Variables_Set ( const Variable v,
const Variable w 
)

Builds the set of variables's indexes in the range from v.id() to w.id().

If v.id() <= w.id(), this constructor builds the set of variables' indexes v.id(), v.id()+1, ..., w.id(). The empty set is built otherwise.

Definition at line 30 of file Variables_Set.cc.

References Parma_Polyhedra_Library::Variable::id(), and insert().

00031   : Base() {
00032   for (dimension_type d = v.id(), last = w.id(); d <= last; ++d)
00033     insert(d);
00034 }


Member Function Documentation

void Parma_Polyhedra_Library::Variables_Set::ascii_dump ( std::ostream &  s  )  const

Writes to s an ASCII representation of *this.

Definition at line 59 of file Variables_Set.cc.

00059                                                 {
00060   dimension_type variables_set_size = size();
00061   s << "\nvariables( " << variables_set_size << " )\n";
00062   for (Variables_Set::const_iterator i = begin(),
00063          i_end = end(); i != i_end; ++i)
00064     s << *i << " ";
00065 }

void Parma_Polyhedra_Library::Variables_Set::ascii_dump (  )  const

Writes to std::cerr an ASCII representation of *this.

Referenced by Parma_Polyhedra_Library::PIP_Problem::ascii_dump(), and Parma_Polyhedra_Library::MIP_Problem::ascii_dump().

bool Parma_Polyhedra_Library::Variables_Set::ascii_load ( std::istream &  s  ) 

Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise.

Definition at line 70 of file Variables_Set.cc.

00070                                           {
00071   clear();
00072   std::string str;
00073  if (!(s >> str) || str != "variables(")
00074     return false;
00075 
00076   dimension_type size;
00077 
00078   if (!(s >> size))
00079     return false;
00080 
00081   if (!(s >> str) || str != ")")
00082     return false;
00083 
00084   dimension_type variable_value;
00085   for (dimension_type i = 0; i < size; ++i) {
00086     if (!(s >> variable_value))
00087       return false;
00088     insert(variable_value);
00089   }
00090   return true;
00091 }

memory_size_type Parma_Polyhedra_Library::Variables_Set::external_memory_in_bytes (  )  const [inline]

Returns the size in bytes of the memory managed by *this.

Definition at line 60 of file Variables_Set.inlines.hh.

Referenced by total_memory_in_bytes().

00060                                               {
00061   // We assume sets are implemented by means of red-black trees that
00062   // require to store the color (we assume an enum) and three pointers
00063   // to the parent, left and right child, respectively.
00064   enum color { red, black };
00065   return size() * (sizeof(color) + 3*sizeof(void*) + sizeof(dimension_type));
00066 }

void Parma_Polyhedra_Library::Variables_Set::insert ( Variable  v  )  [inline]
dimension_type Parma_Polyhedra_Library::Variables_Set::max_space_dimension (  )  [inline, static]

Returns the maximum space dimension a Variables_Set can handle.

Definition at line 49 of file Variables_Set.inlines.hh.

00049                                    {
00050   return Variable::max_space_dimension();
00051 }

bool Parma_Polyhedra_Library::Variables_Set::OK (  )  const

Checks if all the invariants are satisfied.

Definition at line 37 of file Variables_Set.cc.

Referenced by Parma_Polyhedra_Library::PIP_Problem::OK().

00037                            {
00038   for (const_iterator i = begin(), set_end = end(); i != set_end; ++i)
00039     if (!Variable(*i).OK())
00040       return false;
00041   return true;
00042 }

void Parma_Polyhedra_Library::Variables_Set::print (  )  const

Prints *this to std::cerr using operator<<.

dimension_type Parma_Polyhedra_Library::Variables_Set::space_dimension (  )  const [inline]

Returns the dimension of the smallest vector space enclosing all the variables whose indexes are in the set.

Definition at line 54 of file Variables_Set.inlines.hh.

Referenced by Parma_Polyhedra_Library::MIP_Problem::add_to_integer_space_dimensions(), Parma_Polyhedra_Library::PIP_Problem::add_to_parameter_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::drop_some_non_integer_points(), Parma_Polyhedra_Library::Grid::drop_some_non_integer_points(), Parma_Polyhedra_Library::Box< ITV >::drop_some_non_integer_points(), Parma_Polyhedra_Library::BD_Shape< T >::drop_some_non_integer_points(), Parma_Polyhedra_Library::Polyhedron::fold_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::fold_space_dimensions(), Parma_Polyhedra_Library::Grid::fold_space_dimensions(), Parma_Polyhedra_Library::Box< ITV >::fold_space_dimensions(), Parma_Polyhedra_Library::BD_Shape< T >::fold_space_dimensions(), Parma_Polyhedra_Library::MIP_Problem::MIP_Problem(), Parma_Polyhedra_Library::PIP_Problem::PIP_Problem(), Parma_Polyhedra_Library::Polyhedron::remove_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::remove_space_dimensions(), Parma_Polyhedra_Library::Grid_Generator_System::remove_space_dimensions(), Parma_Polyhedra_Library::Grid::remove_space_dimensions(), Parma_Polyhedra_Library::Box< ITV >::remove_space_dimensions(), Parma_Polyhedra_Library::BD_Shape< T >::remove_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::unconstrain(), Parma_Polyhedra_Library::Octagonal_Shape< T >::unconstrain(), Parma_Polyhedra_Library::Grid::unconstrain(), Parma_Polyhedra_Library::Box< ITV >::unconstrain(), Parma_Polyhedra_Library::BD_Shape< T >::unconstrain(), Parma_Polyhedra_Library::Grid::wrap_assign(), and Parma_Polyhedra_Library::Box< ITV >::wrap_assign().

00054                                      {
00055   reverse_iterator i = rbegin();
00056   return i == rend() ? 0 : *i+1;
00057 }

memory_size_type Parma_Polyhedra_Library::Variables_Set::total_memory_in_bytes (  )  const [inline]

Returns the total size in bytes of the memory occupied by *this.

Definition at line 69 of file Variables_Set.inlines.hh.

References external_memory_in_bytes().

00069                                            {
00070   return sizeof(*this) + external_memory_in_bytes();
00071 }


Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  s,
const Variables_Set vs 
) [related]

Output operator.

Definition at line 46 of file Variables_Set.cc.

00046                                                                   {
00047   s << '{';
00048   for (Variables_Set::const_iterator i = vs.begin(),
00049          vs_end = vs.end(); i != vs_end; ) {
00050     s << ' ' << Variable(*i++);
00051     if (i != vs_end)
00052       s << ',';
00053   }
00054   s << " }";
00055   return s;
00056 }


The documentation for this class was generated from the following files:
Generated on Sun Feb 27 16:20:23 2011 for PPL by  doxygen 1.6.3