00001 /* Powerset class declaration. 00002 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it> 00003 Copyright (C) 2010-2011 BUGSENG srl (http://bugseng.com) 00004 00005 This file is part of the Parma Polyhedra Library (PPL). 00006 00007 The PPL is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 The PPL is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software Foundation, 00019 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. 00020 00021 For the most up-to-date information see the Parma Polyhedra Library 00022 site: http://www.cs.unipr.it/ppl/ . */ 00023 00024 #ifndef PPL_Powerset_defs_hh 00025 #define PPL_Powerset_defs_hh 00026 00027 #include "Powerset.types.hh" 00028 #include "globals.types.hh" 00029 #include "iterator_to_const.defs.hh" 00030 #include <iosfwd> 00031 #include <iterator> 00032 #include <list> 00033 00034 namespace Parma_Polyhedra_Library { 00035 00037 00038 template <typename D> 00039 bool 00040 operator==(const Powerset<D>& x, const Powerset<D>& y); 00041 00043 00044 template <typename D> 00045 bool 00046 operator!=(const Powerset<D>& x, const Powerset<D>& y); 00047 00048 namespace IO_Operators { 00049 00051 00052 template <typename D> 00053 std::ostream& 00054 operator<<(std::ostream& s, const Powerset<D>& x); 00055 00056 } // namespace IO_Operators 00057 00058 } // namespace Parma_Polyhedra_Library 00059 00060 00062 00146 template <typename D> 00147 class Parma_Polyhedra_Library::Powerset { 00148 public: 00150 00151 00156 Powerset(); 00157 00159 Powerset(const Powerset& y); 00160 00165 explicit Powerset(const D& d); 00166 00168 ~Powerset(); 00169 00171 00173 00174 00181 bool definitely_entails(const Powerset& y) const; 00182 00188 bool is_top() const; 00189 00195 bool is_bottom() const; 00196 00201 memory_size_type total_memory_in_bytes() const; 00202 00207 memory_size_type external_memory_in_bytes() const; 00208 00210 // FIXME: document and perhaps use an enum instead of a bool. 00211 bool OK(bool disallow_bottom = false) const; 00212 00214 00215 protected: 00217 00221 typedef std::list<D> Sequence; 00222 00224 typedef typename Sequence::iterator Sequence_iterator; 00225 00227 typedef typename Sequence::const_iterator Sequence_const_iterator; 00228 00230 Sequence sequence; 00231 00233 mutable bool reduced; 00234 00235 public: 00236 // Sequence manipulation types, accessors and modifiers 00237 typedef typename Sequence::size_type size_type; 00238 typedef typename Sequence::value_type value_type; 00239 00250 typedef iterator_to_const<Sequence> iterator; 00251 00253 typedef const_iterator_to_const<Sequence> const_iterator; 00254 00256 typedef std::reverse_iterator<iterator> reverse_iterator; 00257 00259 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 00260 00262 00263 00272 void omega_reduce() const; 00273 00275 size_type size() const; 00276 00281 bool empty() const; 00282 00287 iterator begin(); 00288 00290 iterator end(); 00291 00296 const_iterator begin() const; 00297 00299 const_iterator end() const; 00300 00305 reverse_iterator rbegin(); 00306 00308 reverse_iterator rend(); 00309 00315 const_reverse_iterator rbegin() const; 00316 00318 const_reverse_iterator rend() const; 00319 00321 void add_disjunct(const D& d); 00322 00327 iterator drop_disjunct(iterator position); 00328 00330 void drop_disjuncts(iterator first, iterator last); 00331 00333 void clear(); 00334 00336 00338 00339 00341 Powerset& operator=(const Powerset& y); 00342 00344 void swap(Powerset& y); 00345 00347 void least_upper_bound_assign(const Powerset& y); 00348 00350 00353 void upper_bound_assign(const Powerset& y); 00354 00362 bool upper_bound_assign_if_exact(const Powerset& y); 00363 00365 void meet_assign(const Powerset& y); 00366 00372 void collapse(); 00373 00375 00376 protected: 00381 bool is_omega_reduced() const; 00382 00388 void collapse(unsigned max_disjuncts); 00389 00403 iterator add_non_bottom_disjunct_preserve_reduction(const D& d, 00404 iterator first, 00405 iterator last); 00406 00414 void add_non_bottom_disjunct_preserve_reduction(const D& d); 00415 00424 template <typename Binary_Operator_Assign> 00425 void pairwise_apply_assign(const Powerset& y, 00426 Binary_Operator_Assign op_assign); 00427 00428 private: 00433 bool check_omega_reduced() const; 00434 00439 void collapse(Sequence_iterator sink); 00440 }; 00441 00442 namespace std { 00443 00445 00446 template <typename D> 00447 void swap(Parma_Polyhedra_Library::Powerset<D>& x, 00448 Parma_Polyhedra_Library::Powerset<D>& y); 00449 00450 } // namespace std 00451 00452 #include "Powerset.inlines.hh" 00453 #include "Powerset.templates.hh" 00454 00455 #endif // !defined(PPL_Powerset_defs_hh)
1.6.3