00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PPL_Bit_Matrix_inlines_hh
00024 #define PPL_Bit_Matrix_inlines_hh 1
00025
00026 #include <algorithm>
00027 #include <cassert>
00028
00029 namespace Parma_Polyhedra_Library {
00030
00031 inline
00032 Bit_Matrix::Bit_Matrix()
00033 : rows(),
00034 row_size(0) {
00035 }
00036
00037 inline dimension_type
00038 Bit_Matrix::max_num_rows() {
00039 return std::vector<Bit_Row>().max_size();
00040 }
00041
00042 inline
00043 Bit_Matrix::Bit_Matrix(const dimension_type n_rows,
00044 const dimension_type n_columns)
00045 : rows(n_rows),
00046 row_size(n_columns) {
00047 }
00048
00049 inline
00050 Bit_Matrix::Bit_Matrix(const Bit_Matrix& y)
00051 : rows(y.rows),
00052 row_size(y.row_size) {
00053 }
00054
00055 inline
00056 Bit_Matrix::~Bit_Matrix() {
00057 }
00058
00059 inline void
00060 Bit_Matrix::rows_erase_to_end(const dimension_type first_to_erase) {
00061
00062
00063 assert(first_to_erase <= rows.size());
00064 if (first_to_erase < rows.size())
00065 rows.erase(rows.begin() + first_to_erase, rows.end());
00066 assert(OK());
00067 }
00068
00069 inline void
00070 Bit_Matrix::columns_erase_to_end(const dimension_type first_to_erase) {
00071
00072
00073 assert(first_to_erase <= row_size);
00074 row_size = first_to_erase;
00075 assert(OK());
00076 }
00077
00078 inline void
00079 Bit_Matrix::swap(Bit_Matrix& y) {
00080 std::swap(row_size, y.row_size);
00081 std::swap(rows, y.rows);
00082 }
00083
00084 inline Bit_Row&
00085 Bit_Matrix::operator[](const dimension_type k) {
00086 assert(k < rows.size());
00087 return rows[k];
00088 }
00089
00090 inline const Bit_Row&
00091 Bit_Matrix::operator[](const dimension_type k) const {
00092 assert(k < rows.size());
00093 return rows[k];
00094 }
00095
00096 inline dimension_type
00097 Bit_Matrix::num_columns() const {
00098 return row_size;
00099 }
00100
00101 inline dimension_type
00102 Bit_Matrix::num_rows() const {
00103 return rows.size();
00104 }
00105
00106 inline void
00107 Bit_Matrix::clear() {
00108
00109 std::vector<Bit_Row>().swap(rows);
00110 row_size = 0;
00111 }
00112
00113 inline memory_size_type
00114 Bit_Matrix::total_memory_in_bytes() const {
00115 return sizeof(*this) + external_memory_in_bytes();
00116 }
00117
00118 inline bool
00119 Bit_Matrix::Bit_Row_Less_Than::
00120 operator()(const Bit_Row& x, const Bit_Row& y) const {
00121 return compare(x, y) < 0;
00122 }
00123
00124 inline bool
00125 Bit_Matrix::sorted_contains(const Bit_Row& row) const {
00126 assert(check_sorted());
00127 return std::binary_search(rows.begin(), rows.end(), row,
00128 Bit_Row_Less_Than());
00129 }
00130
00132 inline bool
00133 operator!=(const Bit_Matrix& x, const Bit_Matrix& y) {
00134 return !(x == y);
00135 }
00136
00137 }
00138
00139
00140 namespace std {
00141
00143 inline void
00144 swap(Parma_Polyhedra_Library::Bit_Matrix& x,
00145 Parma_Polyhedra_Library::Bit_Matrix& y) {
00146 x.swap(y);
00147 }
00148
00149 }
00150
00151 #endif // !defined(PPL_Bit_Matrix_inlines_hh)