1#ifndef UTIL_G_P_ARRAY_H
2#define UTIL_G_P_ARRAY_H
11#include <util/containers/PArray.h>
27 template <
typename Data>
112 template <
typename Data>
122 template <
typename Data>
127 if (other.
ptrs_ == 0) {
129 assert(other.
size_ == 0);
141 for (
int i = 0; i <
size_; ++i) {
157 template <
typename Data>
161 if (
this == &other)
return *
this;
164 for (
int i = 0; i < other.
size_; ++i) {
173 template <
typename Data>
186 template <
typename Data>
190 UTIL_THROW(
"Cannot reserve with capacity <=0");
205 for (
int i = 0; i <
size_; ++i) {
206 newPtr[i] =
ptrs_[i];
218 template <
typename Data>
232 template <
typename Data>
247 for (
int i = 0; i <
size_; ++i) {
248 newPtr[i] =
ptrs_[i];
265 template <
typename Data>
272 template <
class Data>
274 {
return (
bool)
ptrs_; }
void reserve(int capacity)
Reserve memory for specified number of elements.
void clear()
Reset to empty state.
bool isAllocated() const
Is this GPArray allocated?
void append(Data &data)
Append an element to the end of the sequence.
GPArray< Data > & operator=(GPArray< Data > const &other)
Assignment, element by element.
virtual ~GPArray()
Destructor.
void deallocate()
Deallocate (delete) underlying array of pointers.
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.