24 #ifndef __DOLFIN_ARRAY_H 25 #define __DOLFIN_ARRAY_H 31 #include <dolfin/common/constants.h> 32 #include <dolfin/log/log.h> 41 template <
typename T>
class Array 47 explicit Array(std::size_t N) : _size(N), _x(new T[N]), _owner(true) {}
50 Array(std::size_t N, T* x) : _size(N), _x(x), _owner(false) {}
63 std::string
str(
bool verbose)
const 69 s <<
str(
false) << std::endl << std::endl;
71 for (std::size_t i = 0; i <
size(); i++)
72 s << i <<
": " << (*
this)[i] << std::endl;
75 s <<
"<Array<T> of size " <<
size() <<
">";
86 { dolfin_assert(i < _size);
return _x[i]; }
90 { dolfin_assert(i < _size);
return _x[i]; }
110 const std::size_t _size;
std::size_t size() const
Return size of array.
Definition: Array.h:81
std::string str(bool verbose) const
Definition: Array.h:63
Array(std::size_t N, T *x)
Construct array from a pointer. Array does not take ownership.
Definition: Array.h:50
const T * data() const
Return pointer to data (const version)
Definition: Array.h:93
Array(std::size_t N)
Create array of size N. Array has ownership.
Definition: Array.h:47
~Array()
Destructor.
Definition: Array.h:53
T * data()
Return pointer to data (non-const version)
Definition: Array.h:97
const T & operator[](std::size_t i) const
Access value of given entry (const version)
Definition: Array.h:85