24 #ifndef PPL_DB_Row_inlines_hh
25 #define PPL_DB_Row_inlines_hh 1
28 #include "assertions.hh"
40 #if PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
41 return ::operator
new(fixed_size + capacity*
sizeof(T));
43 PPL_ASSERT(capacity >= 1);
44 return ::operator
new(fixed_size + (capacity-1)*
sizeof(T));
67 #
if !PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
84 return std::numeric_limits<size_t>::max() /
sizeof(T);
105 template <
typename T>
111 template <
typename T>
117 template <
typename T>
121 #if PPL_DB_ROW_EXTRA_DEBUG
126 template <
typename T>
132 template <
typename T>
135 PPL_ASSERT(k <
size());
139 template <
typename T>
142 PPL_ASSERT(k < size());
146 template <
typename T>
152 template <
typename T>
158 #if PPL_DB_ROW_EXTRA_DEBUG
159 template <
typename T>
162 return this->capacity_;
164 #endif // PPL_DB_ROW_EXTRA_DEBUG
166 template <
typename T>
172 template <
typename T>
175 #
if PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
180 PPL_ASSERT(capacity <= max_size());
181 #if !PPL_CXX_SUPPORTS_ZERO_LENGTH_ARRAYS
186 PPL_ASSERT(x.
impl == 0);
188 #if PPL_DB_ROW_EXTRA_DEBUG
189 PPL_ASSERT(x.capacity_ == 0);
190 x.capacity_ = capacity;
194 template <
typename T>
199 #if PPL_DB_ROW_EXTRA_DEBUG
200 PPL_ASSERT(new_size <= x.capacity_);
202 x.
impl->expand_within_capacity(new_size);
205 template <
typename T>
210 #if PPL_DB_ROW_EXTRA_DEBUG
211 PPL_ASSERT(y.
size() <= x.capacity_);
213 x.
impl->copy_construct_coefficients(*(y.
impl));
216 template <
typename T>
217 template <
typename U>
222 PPL_ASSERT(y.
size() <= capacity && capacity <= max_size());
225 x.
impl->construct_upward_approximation(*(y.
impl));
228 template <
typename T>
232 PPL_ASSERT(sz <= capacity && capacity <= max_size());
234 expand_within_capacity(sz);
237 template <
typename T>
243 template <
typename T>
251 template <
typename T>
257 template <
typename T>
267 template <
typename T>
273 PPL_ASSERT(y.
size() <= capacity && capacity <=
max_size());
278 template <
typename T>
285 PPL_ASSERT(y.
size() <= sz && sz <= capacity && capacity <=
max_size());
291 template <
typename T>
296 template <
typename T>
301 x.
impl->shrink(new_size);
304 template <
typename T>
310 #if PPL_DB_ROW_EXTRA_DEBUG
311 swap(x.capacity_, y.capacity_);
315 template <
typename T>
320 #if PPL_DB_ROW_EXTRA_DEBUG
321 x.capacity_ = y.capacity_;
325 template <
typename T>
333 template <
typename T>
340 template <
typename T>
347 template <
typename T>
354 template <
typename T>
361 template <
typename T>
368 template <
typename T>
375 template <
typename T>
379 return x.
impl->total_memory_in_bytes(capacity);
382 template <
typename T>
388 template <
typename T>
392 #if PPL_DB_ROW_EXTRA_DEBUG
393 return x.
impl->total_memory_in_bytes(x.capacity_);
395 return x.
impl->total_memory_in_bytes();
399 template <
typename T>
406 template <
typename T>
413 template <
typename T>
420 template <
typename T>
429 #endif // !defined(PPL_DB_Row_inlines_hh)
void set_size(dimension_type new_sz)
Sets to new_sz the actual size of *this.
void iter_swap(typename std::vector< DB_Row< T > >::iterator x, typename std::vector< DB_Row< T > >::iterator y)
void assign(DB_Row &y)
Assigns the implementation of y to *this.
T vec_[ 1]
The vector of coefficients.
void swap(CO_Tree &x, CO_Tree &y)
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
void m_swap(DB_Row &y)
Swaps *this with y.
size_t dimension_type
An unsigned integral type for representing space dimensions.
void swap(DB_Row< T > &x, DB_Row< T > &y)
A class to define STL const and non-const iterators from pointer types.
void bump_size()
Increments the size of *this by 1.
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
DB_Row & operator=(const DB_Row &y)
Assignment operator.
void expand_within_capacity(dimension_type new_size)
Expands the row to size new_size.
T & operator[](dimension_type k)
Returns a reference to the element of the row indexed by k.
void allocate(dimension_type capacity)
Allocates memory for a default constructed DB_Row object, allowing for capacity coefficients at most...
dimension_type compute_capacity(dimension_type requested_size, dimension_type maximum_size)
Speculative allocation function.
The base class for the single rows of matrices.
Enable_If< Is_Native< T >::value, memory_size_type >::type external_memory_in_bytes(const T &)
For native types, returns the size in bytes of the memory managed by the type of the (unused) paramet...
~DB_Row_Impl_Handler()
Destructor.
Impl()
Default constructor.
dimension_type size_
The number of coefficients in the row.
The real implementation of a DB_Row object.
void shrink(dimension_type new_size)
Shrinks the row by erasing elements at the end.
iterator end()
Returns the past-the-end iterator.
The entire library is confined to this namespace.
T & operator[](dimension_type k)
Returns a reference to the element of *this indexed by k.
void construct_upward_approximation(const DB_Row< U > &y, dimension_type capacity)
Constructs properly a conservative approximation of y.
iterator begin()
Returns the const iterator pointing to the first element, if *this is not empty; otherwise, returns the past-the-end const iterator.
dimension_type size() const
Gives the number of coefficients currently in use.
DB_Row()
Pre-constructs a row: construction must be completed by construct().
static dimension_type max_size()
Returns the size() of the largest possible DB_Row.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
memory_size_type external_memory_in_bytes() const
Returns a lower bound to the size in bytes of the memory managed by *this.
DB_Row_Impl_Handler()
Default constructor.
dimension_type size() const
Returns the actual size of this.
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type construct(To &to, const From &, Rounding_Dir dir)
The handler of the actual DB_Row implementation.
static dimension_type max_size()
Returns the size() of the largest possible Impl.
bool operator!=(const DB_Row< T > &x, const DB_Row< T > &y)
void copy_construct_coefficients(const DB_Row &y)
Exception-safe copy construction mechanism for coefficients.
void construct(dimension_type sz)
Constructs properly a default-constructed element.
Impl * impl
A pointer to the actual implementation.