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_DB_Row_defs_hh
00025 #define PPL_DB_Row_defs_hh 1
00026
00027 #include "DB_Row.types.hh"
00028 #include "globals.types.hh"
00029 #include "Ptr_Iterator.defs.hh"
00030 #include <cstddef>
00031 #include <vector>
00032
00033 #ifndef PPL_DB_ROW_EXTRA_DEBUG
00034 #ifdef PPL_ABI_BREAKING_EXTRA_DEBUG
00035 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00036
00042 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00043 #define PPL_DB_ROW_EXTRA_DEBUG 1
00044 #else // !defined(PPL_ABI_BREAKING_EXTRA_DEBUG)
00045 #define PPL_DB_ROW_EXTRA_DEBUG 0
00046 #endif // !defined(PPL_ABI_BREAKING_EXTRA_DEBUG)
00047 #endif // !defined(PPL_DB_ROW_EXTRA_DEBUG)
00048
00049
00050 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00051
00052
00056 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00057 template <typename T>
00058 class Parma_Polyhedra_Library::DB_Row_Impl_Handler {
00059 public:
00061 DB_Row_Impl_Handler();
00062
00064 ~DB_Row_Impl_Handler();
00065
00066 class Impl;
00067
00069 Impl* impl;
00070
00071 #if PPL_DB_ROW_EXTRA_DEBUG
00072
00073 dimension_type capacity_;
00074 #endif // PPL_DB_ROW_EXTRA_DEBUG
00075
00076 private:
00078 DB_Row_Impl_Handler(const DB_Row_Impl_Handler&);
00079
00081 DB_Row_Impl_Handler& operator=(const DB_Row_Impl_Handler&);
00082 };
00083
00084 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00085
00086
00118 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00119 template <typename T>
00120 class Parma_Polyhedra_Library::DB_Row : private DB_Row_Impl_Handler<T> {
00121 public:
00123 DB_Row();
00124
00126
00127
00128
00131 void construct(dimension_type sz);
00132
00134
00145 void construct(dimension_type sz, dimension_type capacity);
00146
00148
00159 template <typename U>
00160 void construct_upward_approximation(const DB_Row<U>& y,
00161 dimension_type capacity);
00162
00164
00166 DB_Row(dimension_type sz);
00167
00169 DB_Row(dimension_type sz, dimension_type capacity);
00170
00172 DB_Row(const DB_Row& y);
00173
00175
00178 DB_Row(const DB_Row& y, dimension_type capacity);
00179
00181
00186 DB_Row(const DB_Row& y, dimension_type sz, dimension_type capacity);
00187
00189 ~DB_Row();
00190
00192 DB_Row& operator=(const DB_Row& y);
00193
00195 void swap(DB_Row& y);
00196
00198 void assign(DB_Row& y);
00199
00208 void allocate(dimension_type capacity);
00209
00211
00218 void expand_within_capacity(dimension_type new_size);
00219
00221
00226 void shrink(dimension_type new_size);
00227
00229 static dimension_type max_size();
00230
00232 dimension_type size() const;
00233
00235
00236
00237 T& operator[](dimension_type k);
00238
00240 const T& operator[](dimension_type k) const;
00242
00244 typedef Implementation::Ptr_Iterator<T*> iterator;
00245
00247 typedef Implementation::Ptr_Iterator<const T*> const_iterator;
00248
00254 iterator begin();
00255
00257 iterator end();
00258
00264 const_iterator begin() const;
00265
00267 const_iterator end() const;
00268
00273 memory_size_type total_memory_in_bytes() const;
00274
00279 memory_size_type external_memory_in_bytes() const;
00280
00285 memory_size_type total_memory_in_bytes(dimension_type capacity) const;
00286
00291 memory_size_type external_memory_in_bytes(dimension_type capacity) const;
00292
00294 bool OK(dimension_type row_size, dimension_type row_capacity) const;
00295
00296 private:
00297 template <typename U> friend class Parma_Polyhedra_Library::DB_Row;
00298
00300 void copy_construct_coefficients(const DB_Row& y);
00301
00302 #if PPL_DB_ROW_EXTRA_DEBUG
00303
00304 dimension_type capacity() const;
00305 #endif // PPL_DB_ROW_EXTRA_DEBUG
00306 };
00307
00308 namespace Parma_Polyhedra_Library {
00309
00310 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00311
00312
00313 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00314
00315 template <typename T>
00316 bool operator==(const DB_Row<T>& x, const DB_Row<T>& y);
00317
00319 template <typename T>
00320 bool operator!=(const DB_Row<T>& x, const DB_Row<T>& y);
00321 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00322
00323 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00324
00325 }
00326
00327
00328 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00329
00330
00335 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00336 template <typename T>
00337 class Parma_Polyhedra_Library::DB_Row_Impl_Handler<T>::Impl {
00338 public:
00340
00341
00347 static void* operator new(size_t fixed_size, dimension_type capacity);
00348
00350 static void operator delete(void* p);
00351
00356 static void operator delete(void* p, dimension_type capacity);
00358
00360 Impl();
00361
00363
00367 ~Impl();
00368
00370
00373 void expand_within_capacity(dimension_type new_size);
00374
00376
00379 void shrink(dimension_type new_size);
00380
00382 void copy_construct_coefficients(const Impl& y);
00383
00388 template <typename U>
00389 void construct_upward_approximation(const U& y);
00390
00392 static dimension_type max_size();
00393
00395
00396
00397 dimension_type size() const;
00398
00400 void set_size(dimension_type new_sz);
00401
00403 void bump_size();
00405
00407
00408
00409 T& operator[](dimension_type k);
00410
00412 const T& operator[](dimension_type k) const;
00414
00419 memory_size_type total_memory_in_bytes() const;
00420
00422 memory_size_type total_memory_in_bytes(dimension_type capacity) const;
00423
00425 memory_size_type external_memory_in_bytes() const;
00426
00427 private:
00428 friend class DB_Row<T>;
00429
00431 dimension_type size_;
00432
00434 T vec_[
00435 #if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00436 1
00437 #endif
00438 ];
00439
00441 Impl(const Impl& y);
00442
00444 Impl& operator=(const Impl&);
00445
00447 void copy_construct(const Impl& y);
00448 };
00449
00450 namespace std {
00451
00452 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00453
00454
00455 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00456 template <typename T>
00457 void swap(Parma_Polyhedra_Library::DB_Row<T>& x,
00458 Parma_Polyhedra_Library::DB_Row<T>& y);
00459
00460 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00461
00462
00463 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00464 template <typename T>
00465 void iter_swap(typename std::vector<Parma_Polyhedra_Library::DB_Row<T> >
00466 ::iterator x,
00467 typename std::vector<Parma_Polyhedra_Library::DB_Row<T> >
00468 ::iterator y);
00469
00470 }
00471
00472 #include "DB_Row.inlines.hh"
00473 #include "DB_Row.templates.hh"
00474
00475 #endif // !defined(PPL_DB_Row_defs_hh)