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