1#ifndef UTIL_D_P_ARRAY_H 
    2#define UTIL_D_P_ARRAY_H 
   11#include <util/containers/PArray.h> 
   12#include <util/misc/Memory.h> 
   23   template <
typename Data>
 
  100   template <
typename Data>
 
  110   template <
typename Data>
 
  115         UTIL_THROW(
"Inconsistent size and capacity");
 
  119         Memory::allocate<Data*>(ptrs_, other.capacity_);
 
  120         capacity_ = other.capacity_;
 
  122         for (int i = 0; i < other.size_; ++i) {
 
  123            ptrs_[i] = other.ptrs_[i];
 
 
  138   template <
typename Data>
 
  143      if (
this == &other) 
return *
this;
 
  147         UTIL_THROW(
"LHS DPArray in assignment is not allocated");
 
  149      if (other.
ptrs_ == 0) {
 
  150         UTIL_THROW(
"RHS DPArray in assignment is not allocated");
 
  158      for (i = 0; i < other.
size_; ++i) {
 
 
  176   template <
typename Data>
 
  190   template <
typename Data>
 
  198         UTIL_THROW(
"Cannot allocate a DPArray with capacity <=0");
 
 
  207   template <
typename Data>
 
  211         UTIL_THROW(
"Error: Attempt to append to unallocated DPArray");
 
  214         UTIL_THROW(
"Error: Attempt to append data to a full DPArray");
 
 
  223   template <
typename Data>
 
  233   template <
typename Data>
 
  236   { 
return (
bool)
ptrs_;  }
 
 
bool isAllocated() const
Is this DPArray allocated?
virtual ~DPArray()
Destructor.
void allocate(int capacity)
Allocate an array of pointers to Data.
void clear()
Reset to empty state.
DPArray< Data > & operator=(DPArray< Data > const &other)
Assignment, element by element.
void append(Data &data)
Append an element to the end of the sequence.
static void deallocate(Data *&ptr, size_t size)
Deallocate a C++ array.
static void allocate(Data *&ptr, size_t size)
Allocate a C++ array.
int capacity_
Allocated size of ptrs_ array.
int capacity() const
Return allocated size.
PArray()
Constructor (protected to prevent instantiation).
int size_
Logical size (number of elements with initialized data).
Data ** ptrs_
PArray of of pointers to Data objects.
File containing preprocessor macros for error handling.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Utility classes for scientific computation.