PPL  1.2
Parma_Polyhedra_Library::Variables_Set Class Reference

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

#include <Variables_Set_defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::Variables_Set:
Collaboration diagram for Parma_Polyhedra_Library::Variables_Set:

Public Member Functions

 Variables_Set ()
 Builds the empty set of variable indexes. More...
 
 Variables_Set (const Variable v)
 Builds the singleton set of indexes containing v.id();. More...
 
 Variables_Set (const Variable v, const Variable w)
 Builds the set of variables's indexes in the range from v.id() to w.id(). More...
 
dimension_type space_dimension () const
 Returns the dimension of the smallest vector space enclosing all the variables whose indexes are in the set. More...
 
void insert (Variable v)
 Inserts the index of variable v into the set. More...
 
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. More...
 
memory_size_type total_memory_in_bytes () const
 Returns the total size in bytes of the memory occupied by *this. More...
 
memory_size_type external_memory_in_bytes () const
 Returns the size in bytes of the memory managed by *this. More...
 
bool OK () const
 Checks if all the invariants are satisfied. More...
 
void ascii_dump () const
 Writes to std::cerr an ASCII representation of *this. More...
 
void ascii_dump (std::ostream &s) const
 Writes to s an ASCII representation of *this. More...
 
void print () const
 Prints *this to std::cerr using operator<<. More...
 

Static Public Member Functions

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

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 &vs)
 
std::ostream & operator<< (std::ostream &s, const Variables_Set &vs)
 Output operator. More...
 

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.

34  : Base() {
35 }
Parma_Polyhedra_Library::Variables_Set::Variables_Set ( const Variable  v)
inlineexplicit

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

Definition at line 43 of file Variables_Set_inlines.hh.

References insert().

44  : Base() {
45  insert(v);
46 }
void insert(Variable v)
Inserts the index of variable v into the set.
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().

31  : Base() {
32  for (dimension_type d = v.id(), last = w.id(); d <= last; ++d) {
33  insert(d);
34  }
35 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
void insert(Variable v)
Inserts the index of variable v into the set.

Member Function Documentation

void Parma_Polyhedra_Library::Variables_Set::ascii_dump ( ) const

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

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

Writes to s an ASCII representation of *this.

Definition at line 65 of file Variables_Set.cc.

65  {
66  const dimension_type variables_set_size = size();
67  s << "\nvariables( " << variables_set_size << " )\n";
68  for (Variables_Set::const_iterator i = begin(),
69  i_end = end(); i != i_end; ++i) {
70  s << *i << " ";
71  }
72 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
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 77 of file Variables_Set.cc.

77  {
78  clear();
79  std::string str;
80  if (!(s >> str) || str != "variables(") {
81  return false;
82  }
83 
84  dimension_type size;
85 
86  if (!(s >> size)) {
87  return false;
88  }
89 
90  if (!(s >> str) || str != ")") {
91  return false;
92  }
93 
94  for (dimension_type i = 0; i < size; ++i) {
95  dimension_type variable_value;
96  if (!(s >> variable_value)) {
97  return false;
98  }
99  insert(variable_value);
100  }
101  return true;
102 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
void insert(Variable v)
Inserts the index of variable v into the set.
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().

60  {
61  // We assume sets are implemented by means of red-black trees that
62  // require to store the color (we assume an enum) and three pointers
63  // to the parent, left and right child, respectively.
64  enum color { red, black };
65  return size() * (sizeof(color) + 3*sizeof(void*) + sizeof(dimension_type));
66 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type Parma_Polyhedra_Library::Variables_Set::max_space_dimension ( )
inlinestatic

Returns the maximum space dimension a Variables_Set can handle.

Definition at line 49 of file Variables_Set_inlines.hh.

References Parma_Polyhedra_Library::Variable::max_space_dimension().

49  {
51 }
static dimension_type max_space_dimension()
Returns the maximum space dimension a Variable can handle.
bool Parma_Polyhedra_Library::Variables_Set::OK ( ) const

Checks if all the invariants are satisfied.

Definition at line 38 of file Variables_Set.cc.

References Parma_Polyhedra_Library::Variable::OK().

38  {
39  for (const_iterator i = begin(), set_end = end();
40  i != set_end; ++i) {
41  if (!Variable(*i).OK()) {
42  return false;
43  }
44  }
45  return true;
46 }
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::Expression_Hide_Last< T >::all_zeroes(), Parma_Polyhedra_Library::MIP_Problem::choose_branching_variable(), Parma_Polyhedra_Library::Box< ITV >::drop_some_non_integer_points(), Parma_Polyhedra_Library::Octagonal_Shape< T >::drop_some_non_integer_points(), Parma_Polyhedra_Library::BD_Shape< T >::drop_some_non_integer_points(), Parma_Polyhedra_Library::Grid::drop_some_non_integer_points(), Parma_Polyhedra_Library::Box< ITV >::fold_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::fold_space_dimensions(), Parma_Polyhedra_Library::BD_Shape< T >::fold_space_dimensions(), Parma_Polyhedra_Library::Grid::fold_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::fold_space_dimensions(), Parma_Polyhedra_Library::MIP_Problem::MIP_Problem(), Parma_Polyhedra_Library::PIP_Problem::PIP_Problem(), Parma_Polyhedra_Library::Linear_Expression_Impl< Row >::remove_space_dimensions(), Parma_Polyhedra_Library::Linear_System< Row >::remove_space_dimensions(), Parma_Polyhedra_Library::Grid_Generator::remove_space_dimensions(), Parma_Polyhedra_Library::Generator::remove_space_dimensions(), Parma_Polyhedra_Library::Box< ITV >::remove_space_dimensions(), Parma_Polyhedra_Library::Octagonal_Shape< T >::remove_space_dimensions(), Parma_Polyhedra_Library::BD_Shape< T >::remove_space_dimensions(), Parma_Polyhedra_Library::Grid::remove_space_dimensions(), Parma_Polyhedra_Library::Polyhedron::remove_space_dimensions(), Parma_Polyhedra_Library::Box< ITV >::unconstrain(), Parma_Polyhedra_Library::Polyhedron::unconstrain(), Parma_Polyhedra_Library::Octagonal_Shape< T >::unconstrain(), Parma_Polyhedra_Library::Grid::unconstrain(), Parma_Polyhedra_Library::BD_Shape< T >::unconstrain(), Parma_Polyhedra_Library::Implementation::wrap_assign(), Parma_Polyhedra_Library::Box< ITV >::wrap_assign(), and Parma_Polyhedra_Library::Grid::wrap_assign().

54  {
55  reverse_iterator i = rbegin();
56  return (i == rend()) ? 0 : (*i + 1);
57 }
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().

69  {
70  return sizeof(*this) + external_memory_in_bytes();
71 }
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.

Friends And Related Function Documentation

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

Output operator.

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

Definition at line 50 of file Variables_Set.cc.

50  {
51  s << '{';
52  for (Variables_Set::const_iterator i = vs.begin(),
53  vs_end = vs.end(); i != vs_end; ) {
54  s << ' ' << Variable(*i);
55  ++i;
56  if (i != vs_end) {
57  s << ',';
58  }
59  }
60  s << " }";
61  return s;
62 }

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