PPL  1.2
Bit_Row_defs.hh
Go to the documentation of this file.
1 /* Bit_Row 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_Bit_Row_defs_hh
25 #define PPL_Bit_Row_defs_hh 1
26 
27 #include "Bit_Row_types.hh"
28 #include "globals_types.hh"
29 #include <iosfwd>
30 #include <gmpxx.h>
31 #include <vector>
32 
33 namespace Parma_Polyhedra_Library {
34 
35 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
36 
38 void swap(Bit_Row& x, Bit_Row& y);
39 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
40 
41 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
42 
44 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
45 void
46 iter_swap(std::vector<Bit_Row>::iterator x,
47  std::vector<Bit_Row>::iterator y);
48 
49 // Put them in the namespace here to declare them friends later.
50 
51 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
52 
54 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
55 bool operator==(const Bit_Row& x, const Bit_Row& y);
56 
57 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
58 
60 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
61 bool operator!=(const Bit_Row& x, const Bit_Row& y);
62 
63 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
64 
76 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
77 int compare(const Bit_Row& x, const Bit_Row& y);
78 
79 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
80 
82 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
83 bool subset_or_equal(const Bit_Row& x, const Bit_Row& y);
84 
85 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
86 
92 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
93 bool subset_or_equal(const Bit_Row& x, const Bit_Row& y,
94  bool& strict_subset);
95 
96 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
97 
99 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
100 bool strict_subset(const Bit_Row& x, const Bit_Row& y);
101 
102 } // namespace Parma_Polyhedra_Library
103 
104 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
105 
107 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
109 public:
111  Bit_Row();
112 
114  Bit_Row(const Bit_Row& y);
115 
117 
120  Bit_Row(const Bit_Row& y, const Bit_Row& z);
121 
123  ~Bit_Row();
124 
126  Bit_Row& operator=(const Bit_Row& y);
127 
129  void m_swap(Bit_Row& y);
130 
132  bool operator[](unsigned long k) const;
133 
135  void set(unsigned long k);
136 
138  void set_until(unsigned long k);
139 
141  void clear(unsigned long k);
142 
144  void clear_from(unsigned long k);
145 
147  void clear();
148 
150  void union_assign(const Bit_Row& x, const Bit_Row& y);
151 
153  void intersection_assign(const Bit_Row& x, const Bit_Row& y);
154 
156  void difference_assign(const Bit_Row& x, const Bit_Row& y);
157 
158 
159  friend int compare(const Bit_Row& x, const Bit_Row& y);
160  friend bool operator==(const Bit_Row& x, const Bit_Row& y);
161  friend bool operator!=(const Bit_Row& x, const Bit_Row& y);
162  friend bool subset_or_equal(const Bit_Row& x, const Bit_Row& y);
163  friend bool subset_or_equal(const Bit_Row& x, const Bit_Row& y,
164  bool& strict_subset);
165  friend bool strict_subset(const Bit_Row& x, const Bit_Row& y);
166 
168  unsigned long first() const;
169 
174  unsigned long next(unsigned long position) const;
175 
177  unsigned long last() const;
178 
183  unsigned long prev(unsigned long position) const;
184 
186  unsigned long count_ones() const;
187 
189  bool empty() const;
190 
193 
196 
198  bool OK() const;
199 
200 private:
202  mpz_t vec;
203 
205 
209  void union_helper(const Bit_Row& y, const Bit_Row& z);
210 };
211 
212 #include "Bit_Row_inlines.hh"
213 
214 #endif // !defined(PPL_Bit_Row_defs_hh)
void set_until(unsigned long k)
Sets bits up to position k (excluded).
Definition: Bit_Row.cc:166
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
Definition: Box_inlines.hh:264
bool OK() const
Checks if all the invariants are satisfied.
Definition: Bit_Row.cc:331
void swap(CO_Tree &x, CO_Tree &y)
void intersection_assign(const Bit_Row &x, const Bit_Row &y)
Assigns to *this the set-theoretic intersection of x and y.
void union_assign(const Bit_Row &x, const Bit_Row &y)
Assigns to *this the set-theoretic union of x and y.
unsigned long last() const
Returns the index of the last set bit or ULONG_MAX if no bit is set.
Definition: Bit_Row.cc:92
friend bool operator==(const Bit_Row &x, const Bit_Row &y)
unsigned long prev(unsigned long position) const
Returns the index of the first set bit before position or ULONG_MAX if no bits before position is set...
Definition: Bit_Row.cc:107
Bit_Row & operator=(const Bit_Row &y)
Assignment operator.
void set(unsigned long k)
Sets the bit in position k.
void difference_assign(const Bit_Row &x, const Bit_Row &y)
Assigns to *this the set-theoretic difference of x and y.
unsigned long count_ones() const
Returns the number of set bits in the row.
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
friend bool operator!=(const Bit_Row &x, const Bit_Row &y)
A row in a matrix of bits.
mpz_t vec
Bit-vector representing the row.
friend bool subset_or_equal(const Bit_Row &x, const Bit_Row &y)
bool empty() const
Returns true if no bit is set in the row.
friend int compare(const Bit_Row &x, const Bit_Row &y)
unsigned long first() const
Returns the index of the first set bit or ULONG_MAX if no bit is set.
Definition: Bit_Row.cc:32
int compare(const Linear_Expression &x, const Linear_Expression &y)
void m_swap(Bit_Row &y)
Swaps *this with y.
bool operator[](unsigned long k) const
Returns the truth value corresponding to the bit in position k.
Definition: Bit_Row.cc:152
void clear()
Clears all the bits of the row.
void clear_from(unsigned long k)
Clears bits from position k (included) onward.
The entire library is confined to this namespace.
Definition: version.hh:61
Bit_Row()
Default constructor.
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
unsigned long next(unsigned long position) const
Returns the index of the first set bit after position or ULONG_MAX if no bit after position is set...
Definition: Bit_Row.cc:47
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
void union_helper(const Bit_Row &y, const Bit_Row &z)
Assigns to *this the union of y and z.
Definition: Bit_Row.cc:340
friend bool strict_subset(const Bit_Row &x, const Bit_Row &y)