Parma_Polyhedra_Library::Row_Impl_Handler::Impl Class Reference
[C++ Language Interface]

The actual implementation of a Row object. More...

#include <Row.defs.hh>

Collaboration diagram for Parma_Polyhedra_Library::Row_Impl_Handler::Impl:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Impl (Row::Flags f)
 Constructor.
 ~Impl ()
 Destructor.
void expand_within_capacity (dimension_type new_size)
 Expands the row to size new_size.
void shrink (dimension_type new_size)
 Shrinks the row by erasing elements at the end.
void copy_construct_coefficients (const Impl &y)
 Exception-safe copy construction mechanism for coefficients.
memory_size_type total_memory_in_bytes () const
 Returns a lower bound to the total size in bytes of the memory occupied by *this.
memory_size_type total_memory_in_bytes (dimension_type capacity) const
 Returns the total size in bytes of the memory occupied by *this.
memory_size_type external_memory_in_bytes () const
 Returns the size in bytes of the memory managed by *this.
Flags accessors
const Row::Flagsflags () const
 Returns a const reference to the flags of *this.
Row::Flagsflags ()
 Returns a non-const reference to the flags of *this.
Size accessors
dimension_type size () const
 Returns the actual size of this.
void set_size (dimension_type new_size)
 Sets to new_size the actual size of *this.
void bump_size ()
 Increment the size of *this by 1.
Subscript operators
Coefficientoperator[] (dimension_type k)
 Returns a reference to the element of *this indexed by k.
Coefficient_traits::const_reference operator[] (dimension_type k) const
 Returns a constant reference to the element of *this indexed by k.

Static Public Member Functions

static dimension_type max_size ()
 Returns the size() of the largest possible Impl.
Custom allocator and deallocator
static void * operator new (size_t fixed_size, dimension_type capacity)
 Allocates a chunk of memory able to contain capacity Coefficient objects beyond the specified fixed_size and returns a pointer to the new allocated memory.
static void operator delete (void *p)
 Uses the standard delete operator to free the memory p points to.
static void operator delete (void *p, dimension_type capacity)
 Placement version: uses the standard operator delete to free the memory p points to.

Private Member Functions

 Impl ()
 Private and unimplemented: default construction is not allowed.
 Impl (const Impl &y)
 Private and unimplemented: copy construction is not allowed.
Imploperator= (const Impl &)
 Private and unimplemented: assignment is not allowed.

Private Attributes

dimension_type size_
 The number of coefficients in the row.
Row::Flags flags_
 The flags of this row.
Coefficient vec_ [1]
 The vector of coefficients.


Detailed Description

The actual implementation of a Row object.

The class Row_Impl_Handler::Impl provides the implementation of Row objects and, in particular, of the corresponding memory allocation functions.

Definition at line 388 of file Row.defs.hh.


Constructor & Destructor Documentation

Parma_Polyhedra_Library::Row_Impl_Handler::Impl::Impl ( Row::Flags  f  )  [inline]

Constructor.

Definition at line 115 of file Row.inlines.hh.

00116   : size_(0), flags_(f) {
00117 }

Parma_Polyhedra_Library::Row_Impl_Handler::Impl::~Impl (  )  [inline]

Destructor.

Uses shrink() method with argument $0$ to delete all the row elements.

Definition at line 120 of file Row.inlines.hh.

References shrink().

00120                             {
00121   shrink(0);
00122 }

Parma_Polyhedra_Library::Row_Impl_Handler::Impl::Impl (  )  [private]

Private and unimplemented: default construction is not allowed.

Parma_Polyhedra_Library::Row_Impl_Handler::Impl::Impl ( const Impl y  )  [private]

Private and unimplemented: copy construction is not allowed.


Member Function Documentation

void * Parma_Polyhedra_Library::Row_Impl_Handler::Impl::operator new ( size_t  fixed_size,
dimension_type  capacity 
) [inline, static]

Allocates a chunk of memory able to contain capacity Coefficient objects beyond the specified fixed_size and returns a pointer to the new allocated memory.

Definition at line 74 of file Row.inlines.hh.

00075                                                                     {
00076 #if PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00077   return ::operator new(fixed_size + capacity*sizeof(Coefficient));
00078 #else
00079   assert(capacity >= 1);
00080   return ::operator new(fixed_size + (capacity-1)*sizeof(Coefficient));
00081 #endif
00082 }

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::operator delete ( void *  p  )  [inline, static]

Uses the standard delete operator to free the memory p points to.

Definition at line 85 of file Row.inlines.hh.

00085                                              {
00086   ::operator delete(p);
00087 }

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::operator delete ( void *  p,
dimension_type  capacity 
) [inline, static]

Placement version: uses the standard operator delete to free the memory p points to.

Definition at line 90 of file Row.inlines.hh.

00090                                                              {
00091   ::operator delete(p);
00092 }

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::expand_within_capacity ( dimension_type  new_size  ) 

Expands the row to size new_size.

It is assumed that new_size is between the current size and capacity.

Definition at line 35 of file Row.cc.

Referenced by Parma_Polyhedra_Library::Row::expand_within_capacity().

00035                                                           {
00036   assert(size() <= new_size && new_size <= max_size());
00037 #if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00038   // vec_[0] is already constructed.
00039   if (size() == 0 && new_size > 0)
00040     bump_size();
00041 #endif
00042   for (dimension_type i = size(); i < new_size; ++i) {
00043     new (&vec_[i]) Coefficient();
00044     bump_size();
00045   }
00046 }

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::shrink ( dimension_type  new_size  ) 

Shrinks the row by erasing elements at the end.

It is assumed that new_size is not greater than the current size.

Definition at line 49 of file Row.cc.

References set_size(), size(), and vec_.

Referenced by Parma_Polyhedra_Library::Row::shrink(), and ~Impl().

00049                                                        {
00050   const dimension_type old_size = size();
00051   assert(new_size <= old_size);
00052   // Since ~Coefficient() does not throw exceptions, nothing here does.
00053   set_size(new_size);
00054 #if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00055   // Make sure we do not try to destroy vec_[0].
00056   if (new_size == 0)
00057     ++new_size;
00058 #endif
00059   // We assume construction was done "forward".
00060   // We thus perform destruction "backward".
00061   for (dimension_type i = old_size; i-- > new_size; )
00062     vec_[i].~Coefficient();
00063 }

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::copy_construct_coefficients ( const Impl y  ) 

Exception-safe copy construction mechanism for coefficients.

Definition at line 66 of file Row.cc.

References bump_size(), size(), and vec_.

Referenced by Parma_Polyhedra_Library::Row::copy_construct_coefficients().

00066                                                                   {
00067   const dimension_type y_size = y.size();
00068 #if PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00069   for (dimension_type i = 0; i < y_size; ++i) {
00070     new (&vec_[i]) Coefficient(y.vec_[i]);
00071     bump_size();
00072   }
00073 #else
00074   assert(y_size > 0);
00075   if (y_size > 0) {
00076     vec_[0] = y.vec_[0];
00077     bump_size();
00078     for (dimension_type i = 1; i < y_size; ++i) {
00079       new (&vec_[i]) Coefficient(y.vec_[i]);
00080       bump_size();
00081     }
00082   }
00083 #endif
00084 }

dimension_type Parma_Polyhedra_Library::Row_Impl_Handler::Impl::max_size (  )  [inline, static]

Returns the size() of the largest possible Impl.

Definition at line 95 of file Row.inlines.hh.

Referenced by Parma_Polyhedra_Library::Row::max_size().

00095                                {
00096   return size_t(-1)/sizeof(Coefficient);
00097 }

const Row::Flags & Parma_Polyhedra_Library::Row_Impl_Handler::Impl::flags (  )  const [inline]

Returns a const reference to the flags of *this.

Definition at line 125 of file Row.inlines.hh.

References flags_.

Referenced by Parma_Polyhedra_Library::Row::flags().

00125                                   {
00126   return flags_;
00127 }

Row::Flags & Parma_Polyhedra_Library::Row_Impl_Handler::Impl::flags (  )  [inline]

Returns a non-const reference to the flags of *this.

Definition at line 130 of file Row.inlines.hh.

References flags_.

00130                             {
00131   return flags_;
00132 }

dimension_type Parma_Polyhedra_Library::Row_Impl_Handler::Impl::size (  )  const [inline]

Returns the actual size of this.

Definition at line 100 of file Row.inlines.hh.

References size_.

Referenced by copy_construct_coefficients(), external_memory_in_bytes(), operator[](), shrink(), and Parma_Polyhedra_Library::Row::size().

00100                                  {
00101   return size_;
00102 }

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::set_size ( dimension_type  new_size  )  [inline]

Sets to new_size the actual size of *this.

Definition at line 105 of file Row.inlines.hh.

References size_.

Referenced by shrink().

00105                                                             {
00106   size_ = new_size;
00107 }

void Parma_Polyhedra_Library::Row_Impl_Handler::Impl::bump_size (  )  [inline]

Increment the size of *this by 1.

Definition at line 110 of file Row.inlines.hh.

References size_.

Referenced by copy_construct_coefficients().

00110                                 {
00111   ++size_;
00112 }

Coefficient & Parma_Polyhedra_Library::Row_Impl_Handler::Impl::operator[] ( dimension_type  k  )  [inline]

Returns a reference to the element of *this indexed by k.

Definition at line 135 of file Row.inlines.hh.

References size(), and vec_.

00135                                                        {
00136   assert(k < size());
00137   return vec_[k];
00138 }

Coefficient_traits::const_reference Parma_Polyhedra_Library::Row_Impl_Handler::Impl::operator[] ( dimension_type  k  )  const [inline]

Returns a constant reference to the element of *this indexed by k.

Definition at line 141 of file Row.inlines.hh.

References size(), and vec_.

00141                                                              {
00142   assert(k < size());
00143   return vec_[k];
00144 }

memory_size_type Parma_Polyhedra_Library::Row_Impl_Handler::Impl::total_memory_in_bytes (  )  const [inline]

Returns a lower bound to the total size in bytes of the memory occupied by *this.

Definition at line 158 of file Row.inlines.hh.

References size_.

Referenced by Parma_Polyhedra_Library::Row::external_memory_in_bytes().

00158                                                   {
00159   // In general, this is a lower bound, as the capacity of *this
00160   // may be strictly greater than `size_'
00161   return total_memory_in_bytes(size_);
00162 }

memory_size_type Parma_Polyhedra_Library::Row_Impl_Handler::Impl::total_memory_in_bytes ( dimension_type  capacity  )  const [inline]

Returns the total size in bytes of the memory occupied by *this.

Definition at line 147 of file Row.inlines.hh.

References external_memory_in_bytes().

00147                                                                          {
00148   return
00149     sizeof(*this)
00150     + capacity*sizeof(Coefficient)
00151 #if !PPL_CXX_SUPPORTS_FLEXIBLE_ARRAYS
00152     - 1*sizeof(Coefficient)
00153 #endif
00154     + external_memory_in_bytes();
00155 }

PPL::memory_size_type Parma_Polyhedra_Library::Row_Impl_Handler::Impl::external_memory_in_bytes (  )  const

Returns the size in bytes of the memory managed by *this.

Definition at line 202 of file Row.cc.

References Parma_Polyhedra_Library::external_memory_in_bytes(), size(), and vec_.

Referenced by total_memory_in_bytes().

00202                                                         {
00203   memory_size_type n = 0;
00204   for (dimension_type i = size(); i-- > 0; )
00205     n += PPL::external_memory_in_bytes(vec_[i]);
00206   return n;
00207 }

Impl& Parma_Polyhedra_Library::Row_Impl_Handler::Impl::operator= ( const Impl  )  [private]

Private and unimplemented: assignment is not allowed.


Member Data Documentation

The number of coefficients in the row.

Definition at line 482 of file Row.defs.hh.

Referenced by bump_size(), set_size(), size(), and total_memory_in_bytes().

The flags of this row.

Definition at line 485 of file Row.defs.hh.

Referenced by flags().

The vector of coefficients.

Definition at line 492 of file Row.defs.hh.

Referenced by copy_construct_coefficients(), external_memory_in_bytes(), operator[](), and shrink().


The documentation for this class was generated from the following files:

Generated on Sat Oct 11 10:41:04 2008 for PPL by  doxygen 1.5.6