PPL  0.12.1
Powerset.inlines.hh
Go to the documentation of this file.
00001 /* Powerset class implementation: inline functions.
00002    Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
00003    Copyright (C) 2010-2012 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://bugseng.com/products/ppl/ . */
00023 
00024 #ifndef PPL_Powerset_inlines_hh
00025 #define PPL_Powerset_inlines_hh 1
00026 
00027 #include <algorithm>
00028 #include "assert.hh"
00029 
00030 namespace Parma_Polyhedra_Library {
00031 
00032 template <typename D>
00033 inline typename Powerset<D>::iterator
00034 Powerset<D>::begin() {
00035   return sequence.begin();
00036 }
00037 
00038 template <typename D>
00039 inline typename Powerset<D>::iterator
00040 Powerset<D>::end() {
00041   return sequence.end();
00042 }
00043 
00044 template <typename D>
00045 inline typename Powerset<D>::const_iterator
00046 Powerset<D>::begin() const {
00047   return sequence.begin();
00048 }
00049 
00050 template <typename D>
00051 inline typename Powerset<D>::const_iterator
00052 Powerset<D>::end() const {
00053   return sequence.end();
00054 }
00055 
00056 template <typename D>
00057 inline typename Powerset<D>::reverse_iterator
00058 Powerset<D>::rbegin() {
00059   return reverse_iterator(end());
00060 }
00061 
00062 template <typename D>
00063 inline typename Powerset<D>::reverse_iterator
00064 Powerset<D>::rend() {
00065   return reverse_iterator(begin());
00066 }
00067 
00068 template <typename D>
00069 inline typename Powerset<D>::const_reverse_iterator
00070 Powerset<D>::rbegin() const {
00071   return const_reverse_iterator(end());
00072 }
00073 
00074 template <typename D>
00075 inline typename Powerset<D>::const_reverse_iterator
00076 Powerset<D>::rend() const {
00077   return const_reverse_iterator(begin());
00078 }
00079 
00080 template <typename D>
00081 inline typename Powerset<D>::size_type
00082 Powerset<D>::size() const {
00083   return sequence.size();
00084 }
00085 
00086 template <typename D>
00087 inline bool
00088 Powerset<D>::empty() const {
00089   return sequence.empty();
00090 }
00091 
00092 template <typename D>
00093 inline typename Powerset<D>::iterator
00094 Powerset<D>::drop_disjunct(iterator position) {
00095   return sequence.erase(position.base);
00096 }
00097 
00098 template <typename D>
00099 inline void
00100 Powerset<D>::drop_disjuncts(iterator first, iterator last) {
00101   sequence.erase(first.base, last.base);
00102 }
00103 
00104 template <typename D>
00105 inline void
00106 Powerset<D>::clear() {
00107   sequence.clear();
00108 }
00109 
00110 template <typename D>
00111 inline
00112 Powerset<D>::Powerset(const Powerset& y)
00113   : sequence(y.sequence), reduced(y.reduced) {
00114 }
00115 
00116 template <typename D>
00117 inline Powerset<D>&
00118 Powerset<D>::operator=(const Powerset& y) {
00119   sequence = y.sequence;
00120   reduced = y.reduced;
00121   return *this;
00122 }
00123 
00124 template <typename D>
00125 inline void
00126 Powerset<D>::m_swap(Powerset& y) {
00127   using std::swap;
00128   swap(sequence, y.sequence);
00129   swap(reduced, y.reduced);
00130 }
00131 
00132 template <typename D>
00133 inline
00134 Powerset<D>::Powerset()
00135   : sequence(), reduced(true) {
00136 }
00137 
00138 template <typename D>
00139 inline
00140 Powerset<D>::Powerset(const D& d)
00141   : sequence(), reduced(false) {
00142   sequence.push_back(d);
00143   PPL_ASSERT_HEAVY(OK());
00144 }
00145 
00146 template <typename D>
00147 inline
00148 Powerset<D>::~Powerset() {
00149 }
00150 
00151 template <typename D>
00152 inline void
00153 Powerset<D>::add_non_bottom_disjunct_preserve_reduction(const D& d) {
00154   // !d.is_bottom() is asserted by the callee.
00155   add_non_bottom_disjunct_preserve_reduction(d, begin(), end());
00156 }
00157 
00158 template <typename D>
00159 inline void
00160 Powerset<D>::add_disjunct(const D& d) {
00161   sequence.push_back(d);
00162   reduced = false;
00163 }
00164 
00166 template <typename D>
00167 inline
00168 bool operator!=(const Powerset<D>& x, const Powerset<D>& y) {
00169   return !(x == y);
00170 }
00171 
00172 template <typename D>
00173 inline bool
00174 Powerset<D>::is_top() const {
00175   // Must perform omega-reduction for correctness.
00176   omega_reduce();
00177   const_iterator xi = begin();
00178   const_iterator x_end = end();
00179   return xi != x_end && xi->is_top() && ++xi == x_end;
00180 }
00181 
00182 template <typename D>
00183 inline bool
00184 Powerset<D>::is_bottom() const {
00185   // Must perform omega-reduction for correctness.
00186   omega_reduce();
00187   return empty();
00188 }
00189 
00190 template <typename D>
00191 inline void
00192 Powerset<D>::collapse() {
00193   if (!empty())
00194     collapse(sequence.begin());
00195 }
00196 
00197 template <typename D>
00198 inline void
00199 Powerset<D>::meet_assign(const Powerset& y) {
00200   pairwise_apply_assign(y, std::mem_fun_ref(&D::meet_assign));
00201 }
00202 
00203 template <typename D>
00204 inline void
00205 Powerset<D>::upper_bound_assign(const Powerset& y) {
00206   least_upper_bound_assign(y);
00207 }
00208 
00209 template <typename D>
00210 inline bool
00211 Powerset<D>::upper_bound_assign_if_exact(const Powerset& y) {
00212   least_upper_bound_assign(y);
00213   return true;
00214 }
00215 
00216 template <typename D>
00217 inline memory_size_type
00218 Powerset<D>::total_memory_in_bytes() const {
00219   return sizeof(*this) + external_memory_in_bytes();
00220 }
00221 
00223 template <typename D>
00224 inline void
00225 swap(Powerset<D>& x, Powerset<D>& y) {
00226   x.m_swap(y);
00227 }
00228 
00229 } // namespace Parma_Polyhedra_Library
00230 
00231 #endif // !defined(PPL_Powerset_inlines_hh)