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_Row_defs_hh
00025 #define PPL_Row_defs_hh 1
00026
00027 #include "Row.types.hh"
00028 #include "globals.defs.hh"
00029 #include "Coefficient.defs.hh"
00030 #include <vector>
00031 #include <limits>
00032
00033 #ifndef PPL_ROW_EXTRA_DEBUG
00034 #ifdef PPL_ABI_BREAKING_EXTRA_DEBUG
00035 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00036
00045 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00046 #define PPL_ROW_EXTRA_DEBUG 1
00047 #else // !defined(PPL_ABI_BREAKING_EXTRA_DEBUG)
00048 #define PPL_ROW_EXTRA_DEBUG 0
00049 #endif // !defined(PPL_ABI_BREAKING_EXTRA_DEBUG)
00050 #endif // !defined(PPL_ROW_EXTRA_DEBUG)
00051
00052 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00053
00054
00058 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00059 class Parma_Polyhedra_Library::Row_Impl_Handler {
00060 public:
00062 Row_Impl_Handler();
00063
00065 ~Row_Impl_Handler();
00066
00067 class Impl;
00068
00070 Impl* impl;
00071
00072 #if PPL_ROW_EXTRA_DEBUG
00073
00074 dimension_type capacity_;
00075 #endif // PPL_ROW_EXTRA_DEBUG
00076
00077 private:
00079 Row_Impl_Handler(const Row_Impl_Handler&);
00080
00082 Row_Impl_Handler& operator=(const Row_Impl_Handler&);
00083 };
00084
00085 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00086
00087
00088 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00089 class Parma_Polyhedra_Library::Row : private Row_Impl_Handler {
00090 public:
00091 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00092
00097 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00098 class Flags {
00099 public:
00101 Flags();
00102
00104 bool operator==(const Flags& y) const;
00105
00110 bool operator!=(const Flags& y) const;
00111
00112 PPL_OUTPUT_DECLARATIONS
00113
00115
00120 bool ascii_load(std::istream& s);
00121
00122 protected:
00124 typedef unsigned int base_type;
00125
00127 static const unsigned first_free_bit = 0;
00128
00130 static const unsigned num_bits = std::numeric_limits<base_type>::digits;
00131
00133 explicit Flags(base_type n);
00134
00136 base_type get_bits() const;
00137
00139 void set_bits(base_type mask);
00140
00142 void reset_bits(base_type mask);
00143
00148 bool test_bits(base_type mask) const;
00149
00150 private:
00152 base_type bits;
00153
00154 friend class Row;
00155 };
00156
00158 Row();
00159
00161
00162
00163
00166 void construct(dimension_type sz, Flags f);
00167
00169
00183 void construct(dimension_type sz, dimension_type capacity, Flags f);
00185
00187
00190 Row(dimension_type sz, Flags f);
00191
00193
00207 Row(dimension_type sz, dimension_type capacity, Flags f);
00208
00210 Row(const Row& y);
00211
00213
00217 Row(const Row& y, dimension_type capacity);
00218
00220
00224 Row(const Row& y, dimension_type sz, dimension_type capacity);
00225
00227 ~Row();
00228
00230 Row& operator=(const Row& y);
00231
00233 void swap(Row& y);
00234
00236
00240 void assign(Row& y);
00241
00250 void allocate(dimension_type capacity, Flags f);
00251
00253
00259 void expand_within_capacity(dimension_type new_size);
00260
00262
00267 void shrink(dimension_type new_size);
00268
00270 const Flags& flags() const;
00271
00273 Flags& flags();
00274
00276 static dimension_type max_size();
00277
00279 dimension_type size() const;
00280
00282
00283
00284 Coefficient& operator[](dimension_type k);
00285
00287 Coefficient_traits::const_reference operator[](dimension_type k) const;
00289
00291
00295 void normalize();
00296
00297 PPL_OUTPUT_DECLARATIONS
00298
00304 bool ascii_load(std::istream& s);
00305
00310 memory_size_type total_memory_in_bytes() const;
00311
00316 memory_size_type external_memory_in_bytes() const;
00317
00322 memory_size_type total_memory_in_bytes(dimension_type capacity) const;
00323
00328 memory_size_type external_memory_in_bytes(dimension_type capacity) const;
00329
00331 bool OK() const;
00332
00337 bool OK(dimension_type row_size, dimension_type row_capacity) const;
00338
00339 private:
00341 void copy_construct_coefficients(const Row& y);
00342
00343 #if PPL_ROW_EXTRA_DEBUG
00344
00345 dimension_type capacity() const;
00346 #endif // PPL_ROW_EXTRA_DEBUG
00347 };
00348
00349 namespace Parma_Polyhedra_Library {
00350
00352
00353 bool operator==(const Row& x, const Row& y);
00354
00356
00357 bool operator!=(const Row& x, const Row& y);
00358
00359 }
00360
00361
00362 namespace std {
00363
00364 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00365
00366
00367 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00368 void swap(Parma_Polyhedra_Library::Row& x,
00369 Parma_Polyhedra_Library::Row& y);
00370
00371 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00372
00373
00374 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00375 void iter_swap(std::vector<Parma_Polyhedra_Library::Row>::iterator x,
00376 std::vector<Parma_Polyhedra_Library::Row>::iterator y);
00377
00378 }
00379
00380
00381 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00382
00383
00388 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00389 class Parma_Polyhedra_Library::Row_Impl_Handler::Impl {
00390 public:
00392
00393
00395
00400 static void* operator new(size_t fixed_size, dimension_type capacity);
00401
00403
00417 static void operator delete(void* p);
00418
00420
00423 static void operator delete(void* p, dimension_type capacity);
00425
00427 Impl(Row::Flags f);
00428
00430
00434 ~Impl();
00435
00437
00440 void expand_within_capacity(dimension_type new_size);
00441
00443
00446 void shrink(dimension_type new_size);
00447
00449 void copy_construct_coefficients(const Impl& y);
00450
00452 static dimension_type max_size();
00453
00455
00456
00457 const Row::Flags& flags() const;
00458
00460 Row::Flags& flags();
00462
00464
00465
00466 dimension_type size() const;
00467
00469 void set_size(dimension_type new_size);
00470
00472 void bump_size();
00474
00476
00477
00478 Coefficient& operator[](dimension_type k);
00479
00481 Coefficient_traits::const_reference operator[](dimension_type k) const;
00483
00488 memory_size_type total_memory_in_bytes() const;
00489
00491 memory_size_type total_memory_in_bytes(dimension_type capacity) const;
00492
00494 memory_size_type external_memory_in_bytes() const;
00495
00496 private:
00498 dimension_type size_;
00499
00501 Row::Flags flags_;
00502
00504 Coefficient vec_[
00505 #if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00506 1
00507 #endif
00508 ];
00509
00511 Impl();
00512
00514 Impl(const Impl& y);
00515
00517 Impl& operator=(const Impl&);
00518 };
00519
00520 #include "Row.inlines.hh"
00521
00522 #endif // !defined(PPL_Row_defs_hh)