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>
112 template <
typename Data>
124 for (
int i = 0; i < other.
size_; ++i) {
125 ptrs_[i] = other.
ptrs_[i];
129 if (capacity_ >
size_) {
140 template <
typename Data>
145 if (
this == &other)
return *
this;
149 UTIL_THROW(
"LHS DPArray in assignment is not allocated");
151 if (other.
ptrs_ == 0) {
152 UTIL_THROW(
"RHS DPArray in assignment is not allocated");
160 for (i = 0; i < other.
size_; ++i) {
178 template <
typename Data>
192 template <
typename Data>
200 UTIL_THROW(
"Cannot allocate a DPArray with capacity <=0");
209 template <
typename Data>
213 UTIL_THROW(
"Error: Attempt to append to unallocated DPArray");
216 UTIL_THROW(
"Error: Attempt to append data to a full DPArray");
225 template <
typename Data>
235 template <
typename Data>
238 {
return (
bool)
ptrs_; }
int capacity_
Allocated size of ptrs_ array.
void clear()
Reset to empty state.
void append(Data &data)
Append an element to the end of the sequence.
int capacity() const
Return allocated size.
void allocate(int capacity)
Allocate an array of pointers to Data.
File containing preprocessor macros for error handling.
bool isAllocated() const
Is this DPArray allocated?
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
A dynamic array that only holds pointers to its elements.
Utility classes for scientific computation.
int size_
Logical size (number of elements with initialized data).
virtual ~DPArray()
Destructor.
Data ** ptrs_
PArray of of pointers to Data objects.
DPArray< Data > & operator=(const DPArray< Data > &other)
Assignment, element by element.
An array that only holds pointers to its elements.