array.hpp#

template<typename T>
class Array#

Public Functions

inline Array(size_t n = 0)#

Default constructor

Parameters

n – size of array

inline Array(std::initializer_list<T> l)#
inline Array(Array &&other)#

Construct in host for device from array

Parameters
  • other_arr – array to construct from

  • n – size of array Move constructor; this allows the array to be passed as a return value from a function sapping the pointers and keeping the allocated data on the heap.

inline Array(Array &other)#

Copy constructor; declaring the move constructor makes compiler implicitly declare the copy constructor deleted

inline ~Array()#

Construct in host for device from Array

Parameters
  • otherArray to construct from Copy to host from device

  • otherArray to construct from Desctructor; dealocate heap and set pointer to null

inline T &operator[](size_t i)#

Write access to the array (host)

Parameters

i – index

Returns

reference to i-th element

inline const T &operator[](size_t i) const#

Read only access to the array (host)

Parameters

i – index

Returns

reference to i-th element

inline size_t size() const#

Get array size

Returns

array size

inline void resize(size_t n)#

Resize array droping stored values

Private Members

T *_arr#
size_t _size#
bool _copied#

Functions

template<typename T>
T min(const Array<T> &a)#

Returns the smallest element from an array

Parameters

aArray

Returns

smallest element of a

template<typename T>
T max(const Array<T> &a)#

Returns the larges element from an array

Parameters

aArray

Returns

larges element of a