1 /* Variables_Set class declaration. 2 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it> 3 Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com) 4 5 This file is part of the Parma Polyhedra Library (PPL). 6 7 The PPL is free software; you can redistribute it and/or modify it 8 under the terms of the GNU General Public License as published by the 9 Free Software Foundation; either version 3 of the License, or (at your 10 option) any later version. 11 12 The PPL is distributed in the hope that it will be useful, but WITHOUT 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software Foundation, 19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. 20 21 For the most up-to-date information see the Parma Polyhedra Library 22 site: http://bugseng.com/products/ppl/ . */ 23 24 #ifndef PPL_Variables_Set_defs_hh 25 #define PPL_Variables_Set_defs_hh 1 26 27 #include "Variables_Set_types.hh" 28 #include "Variable_defs.hh" 29 #include "globals_types.hh" 30 #include <iosfwd> 31 #include <set> 32 33 namespace Parma_Polyhedra_Library { 34 35 namespace IO_Operators { 36 37 //! Output operator. 38 /*! \relates Parma_Polyhedra_Library::Variables_Set */ 39 std::ostream& 40 operator<<(std::ostream& s, const Variables_Set& vs); 41 42 } // namespace IO_Operators 43 44 } // namespace Parma_Polyhedra_Library 45 46 //! An std::set of variables' indexes. 47 class Parma_Polyhedra_Library::Variables_Set 48 : public std::set<dimension_type> { 49 private: 50 typedef std::set<dimension_type> Base; 51 52 public: 53 //! Builds the empty set of variable indexes. 54 Variables_Set(); 55 56 //! Builds the singleton set of indexes containing <CODE>v.id()</CODE>; 57 explicit Variables_Set(const Variable v); 58 59 /*! \brief 60 Builds the set of variables's indexes in the range from 61 <CODE>v.id()</CODE> to <CODE>w.id()</CODE>. 62 63 If <CODE>v.id() <= w.id()</CODE>, this constructor builds the 64 set of variables' indexes 65 <CODE>v.id()</CODE>, <CODE>v.id()+1</CODE>, ..., <CODE>w.id()</CODE>. 66 The empty set is built otherwise. 67 */ 68 Variables_Set(const Variable v, const Variable w); 69 70 //! Returns the maximum space dimension a Variables_Set can handle. 71 static dimension_type max_space_dimension(); 72 73 /*! \brief 74 Returns the dimension of the smallest vector space enclosing all 75 the variables whose indexes are in the set. 76 */ 77 dimension_type space_dimension() const; 78 79 //! Inserts the index of variable \p v into the set. 80 void insert(Variable v); 81 82 // The `insert' method above overloads (instead of hiding) the 83 // other `insert' method of std::set. 84 using Base::insert; 85 86 /*! \brief 87 Loads from \p s an ASCII representation (as produced by 88 ascii_dump(std::ostream&) const) and sets \p *this accordingly. 89 Returns <CODE>true</CODE> if successful, <CODE>false</CODE> otherwise. 90 */ 91 bool ascii_load(std::istream& s); 92 93 //! Returns the total size in bytes of the memory occupied by \p *this. 94 memory_size_type total_memory_in_bytes() const; 95 96 //! Returns the size in bytes of the memory managed by \p *this. 97 memory_size_type external_memory_in_bytes() const; 98 99 //! Checks if all the invariants are satisfied. 100 bool OK() const; 101 102 PPL_OUTPUT_DECLARATIONS 103 }; 104 105 #include "Variables_Set_inlines.hh" 106 107 #endif // !defined(PPL_Variables_Set_defs_hh) 108