Compute Library
 22.05
ArrayAccessor< T > Class Template Reference

ArrayAccessor implementation for Array objects. More...

#include <ArrayAccessor.h>

Collaboration diagram for ArrayAccessor< T >:
[legend]

Public Member Functions

 ArrayAccessor (Array< T > &array)
 Create an accessor for the given array. More...
 
 ArrayAccessor (const ArrayAccessor &)=delete
 Prevent instances of this class from being copy constructed. More...
 
ArrayAccessoroperator= (const ArrayAccessor &)=delete
 Prevent instances of this class from being copied. More...
 
 ArrayAccessor (ArrayAccessor &&)=default
 Allow instances of this class to be move constructed. More...
 
ArrayAccessoroperator= (ArrayAccessor &&)=default
 Allow instances of this class to be moved. More...
 
size_t num_values () const override
 Number of elements of the tensor. More...
 
T * buffer () override
 Access to the buffer. More...
 
void resize (size_t num) override
 Resize array. More...
 
T & at (size_t index) const override
 Reference to the element of the array located at the given index. More...
 
- Public Member Functions inherited from IArrayAccessor< T >
virtual ~IArrayAccessor ()=default
 Virtual destructor. More...
 

Additional Inherited Members

- Public Types inherited from IArrayAccessor< T >
using value_type = T
 Array value type. More...
 

Detailed Description

template<typename T>
class arm_compute::test::ArrayAccessor< T >

ArrayAccessor implementation for Array objects.

Definition at line 36 of file ArrayAccessor.h.

Constructor & Destructor Documentation

◆ ArrayAccessor() [1/3]

ArrayAccessor ( Array< T > &  array)
inline

Create an accessor for the given array.

Parameters
[in,out]arrayTo be accessed array.

Definition at line 43 of file ArrayAccessor.h.

References ArrayAccessor< T >::operator=().

44  : _array{ array }
45  {
46  }

◆ ArrayAccessor() [2/3]

ArrayAccessor ( const ArrayAccessor< T > &  )
delete

Prevent instances of this class from being copy constructed.

◆ ArrayAccessor() [3/3]

ArrayAccessor ( ArrayAccessor< T > &&  )
default

Allow instances of this class to be move constructed.

Member Function Documentation

◆ at()

T& at ( size_t  index) const
inlineoverridevirtual

Reference to the element of the array located at the given index.

Parameters
[in]indexIndex of the element
Returns
A reference to the element of the array located at the given index.

Implements IArrayAccessor< T >.

Definition at line 72 of file ArrayAccessor.h.

References ARM_COMPUTE_ERROR_ON, and ArrayAccessor< T >::num_values().

73  {
74  ARM_COMPUTE_ERROR_ON(_array.buffer() == nullptr);
75  ARM_COMPUTE_ERROR_ON(index >= num_values());
76  return _array.buffer()[index];
77  }
size_t num_values() const override
Number of elements of the tensor.
Definition: ArrayAccessor.h:57
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

◆ buffer()

T* buffer ( )
inlineoverridevirtual

Access to the buffer.

Returns
A pointer to the first element in the buffer.

Implements IArrayAccessor< T >.

Definition at line 62 of file ArrayAccessor.h.

63  {
64  return _array.buffer();
65  }

◆ num_values()

size_t num_values ( ) const
inlineoverridevirtual

Number of elements of the tensor.

Returns
the number of elements.

Implements IArrayAccessor< T >.

Definition at line 57 of file ArrayAccessor.h.

Referenced by ArrayAccessor< T >::at().

58  {
59  return _array.num_values();
60  }

◆ operator=() [1/2]

ArrayAccessor& operator= ( const ArrayAccessor< T > &  )
delete

Prevent instances of this class from being copied.

Referenced by ArrayAccessor< T >::ArrayAccessor().

◆ operator=() [2/2]

ArrayAccessor& operator= ( ArrayAccessor< T > &&  )
default

Allow instances of this class to be moved.

◆ resize()

void resize ( size_t  num)
inlineoverridevirtual

Resize array.

Parameters
[in]numThe new array size in number of elements

Implements IArrayAccessor< T >.

Definition at line 67 of file ArrayAccessor.h.

68  {
69  _array.resize(num);
70  }

The documentation for this class was generated from the following file: