PPL  1.2
Bit_Matrix_inlines.hh
Go to the documentation of this file.
1 /* Bit_Matrix class implementation: inline functions.
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_Matrix_inlines_hh
25 #define PPL_Bit_Matrix_inlines_hh 1
26 
27 #include "assertions.hh"
28 #include <algorithm>
29 
30 namespace Parma_Polyhedra_Library {
31 
32 inline
34  : rows(),
35  row_size(0) {
36 }
37 
38 inline dimension_type
40  return std::vector<Bit_Row>().max_size();
41 }
42 
43 inline
45  const dimension_type n_columns)
46  : rows(n_rows),
47  row_size(n_columns) {
48 }
49 
50 inline
52  : rows(y.rows),
53  row_size(y.row_size) {
54 }
55 
56 inline
58 }
59 
60 inline void
62  // The number of rows to be erased cannot be greater
63  // than the actual number of the rows of the matrix.
64  PPL_ASSERT(n <= rows.size());
65  if (n != 0) {
66  rows.resize(rows.size() - n);
67  }
68  PPL_ASSERT(OK());
69 }
70 
71 inline void
73  // The number of columns to be erased cannot be greater
74  // than the actual number of the columns of the matrix.
75  PPL_ASSERT(n <= row_size);
76  row_size -= n;
77  PPL_ASSERT(OK());
78 }
79 
80 inline void
83  std::swap(rows, y.rows);
84 }
85 
86 inline Bit_Row&
88  PPL_ASSERT(k < rows.size());
89  return rows[k];
90 }
91 
92 inline const Bit_Row&
94  PPL_ASSERT(k < rows.size());
95  return rows[k];
96 }
97 
98 inline dimension_type
100  return row_size;
101 }
102 
103 inline dimension_type
105  return rows.size();
106 }
107 
108 inline void
110  // Clear `rows' and minimize its capacity.
111  std::vector<Bit_Row> tmp;
112  std::swap(tmp, rows);
113  row_size = 0;
114 }
115 
116 inline memory_size_type
118  return sizeof(*this) + external_memory_in_bytes();
119 }
120 
121 inline bool
123 operator()(const Bit_Row& x, const Bit_Row& y) const {
124  return compare(x, y) < 0;
125 }
126 
127 inline bool
129  PPL_ASSERT(check_sorted());
130  return std::binary_search(rows.begin(), rows.end(), row,
132 }
133 
135 inline bool
136 operator!=(const Bit_Matrix& x, const Bit_Matrix& y) {
137  return !(x == y);
138 }
139 
141 inline void
143  x.m_swap(y);
144 }
145 
146 } // namespace Parma_Polyhedra_Library
147 
148 #endif // !defined(PPL_Bit_Matrix_inlines_hh)
void swap(CO_Tree &x, CO_Tree &y)
bool operator()(const Bit_Row &x, const Bit_Row &y) const
size_t dimension_type
An unsigned integral type for representing space dimensions.
void swap(Bit_Matrix &x, Bit_Matrix &y)
dimension_type num_rows() const
Returns the number of rows of *this.
bool operator!=(const Bit_Matrix &x, const Bit_Matrix &y)
A row in a matrix of bits.
void remove_trailing_columns(dimension_type n)
Removes the last n columns.
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
void clear()
Clears the matrix deallocating all its rows.
Ordering predicate (used when implementing the sort algorithm).
int compare(const Linear_Expression &x, const Linear_Expression &y)
void remove_trailing_rows(dimension_type n)
Removes the last n rows.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
Definition: Bit_Matrix.cc:225
void m_swap(Bit_Matrix &y)
Swaps *this with y.
bool check_sorted() const
Checks whether *this is sorted. It does NOT check for duplicates.
Definition: Bit_Matrix.cc:263
bool OK() const
Checks if all the invariants are satisfied.
Definition: Bit_Matrix.cc:234
dimension_type num_columns() const
Returns the number of columns of *this.
The entire library is confined to this namespace.
Definition: version.hh:61
static dimension_type max_num_rows()
Returns the maximum number of rows of a Bit_Matrix.
dimension_type row_size
Size of the initialized part of each row.
std::vector< Bit_Row > rows
Contains the rows of the matrix.
bool sorted_contains(const Bit_Row &row) const
Looks for row in *this, which is assumed to be sorted.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
Bit_Row & operator[](dimension_type k)
Subscript operator.