Compute Library
 20.11
IArray< T > Class Template Referenceabstract

Array of type T. More...

#include <IArray.h>

Public Member Functions

 IArray ()
 Default constructor. More...
 
 IArray (size_t max_num_values)
 Constructor: initializes an array which can contain up to max_num_points values. More...
 
size_t max_num_values () const
 Maximum number of values which can be stored in this array. More...
 
virtual ~IArray ()=default
 Default virtual destructor. More...
 
size_t num_values () const
 Number of values currently stored in the array. More...
 
bool push_back (const T &val)
 Append the passed argument to the end of the array if there is room. More...
 
void clear ()
 Clear all the points from the array. More...
 
bool overflow () const
 Did we lose some values because the array is too small? More...
 
virtual T * buffer () const =0
 Pointer to the first element of the array. More...
 
virtual T & at (size_t index) const
 Reference to the element of the array located at the given index. More...
 
void resize (size_t num)
 Resizes the array to contain "num" elements. More...
 

Detailed Description

template<class T>
class arm_compute::IArray< T >

Array of type T.

Definition at line 40 of file IArray.h.

Constructor & Destructor Documentation

◆ IArray() [1/2]

IArray ( )
inline

Default constructor.

Definition at line 44 of file IArray.h.

45  : _num_values(0), _max_size(0) {};

◆ IArray() [2/2]

IArray ( size_t  max_num_values)
inline

Constructor: initializes an array which can contain up to max_num_points values.

Parameters
[in]max_num_valuesMaximum number of values the array will be able to stored

Definition at line 50 of file IArray.h.

51  : _num_values(0), _max_size(max_num_values)
52  {
53  }
size_t max_num_values() const
Maximum number of values which can be stored in this array.
Definition: IArray.h:58

◆ ~IArray()

virtual ~IArray ( )
virtualdefault

Default virtual destructor.

Member Function Documentation

◆ at()

virtual T& at ( size_t  index) const
inlinevirtual

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.

Definition at line 117 of file IArray.h.

118  {
119  ARM_COMPUTE_ERROR_ON(buffer() == nullptr);
121  return buffer()[index];
122  }
#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
virtual T * buffer() const =0
Pointer to the first element of the array.
size_t max_num_values() const
Maximum number of values which can be stored in this array.
Definition: IArray.h:58

Referenced by NEHOGMultiDetection::configure(), CLHOGMultiDetection::configure(), IArray< NELKInternalKeypoint >::push_back(), and CPPDetectionWindowNonMaximaSuppressionKernel::run().

◆ buffer()

virtual T* buffer ( ) const
pure virtual

Pointer to the first element of the array.

Other elements of the array can be accessed using buffer()[idx] for 0 <= idx < num_poins().

Returns
A pointer to the first element of the array

Implemented in ICLArray< T >, ICLArray< cl_float >, ICLArray< cl_int >, Array< T >, and Array< NELKInternalKeypoint >.

Referenced by IArray< NELKInternalKeypoint >::at(), and CPPDetectionWindowNonMaximaSuppressionKernel::run().

◆ clear()

void clear ( )
inline

Clear all the points from the array.

Definition at line 91 of file IArray.h.

92  {
93  _num_values = 0;
94  }

Referenced by NEHOGMultiDetection::run(), and CLHOGMultiDetection::run().

◆ max_num_values()

size_t max_num_values ( ) const
inline

◆ num_values()

size_t num_values ( ) const
inline

Number of values currently stored in the array.

Returns
Number of values currently stored in the array or max_num_values + 1 if the array is overflowed.

Definition at line 68 of file IArray.h.

69  {
70  return _num_values;
71  }

Referenced by CLLKTrackerInitKernel::configure(), NEOpticalFlow::configure(), CLLKTrackerFinalizeKernel::configure(), NEHOGMultiDetection::configure(), CLHOGMultiDetection::configure(), CLOpticalFlow::configure(), CLLKTrackerStage0Kernel::configure(), CLLKTrackerStage1Kernel::configure(), CPPDetectionWindowNonMaximaSuppressionKernel::run(), NEHOGDetectorKernel::run(), and CLHOGDetector::run().

◆ overflow()

bool overflow ( ) const
inline

Did we lose some values because the array is too small?

Returns
True if we tried to add a value using push_back() but there wasn't any room left to store it. False if all the values were successfully added to the array.

Definition at line 100 of file IArray.h.

101  {
102  return _num_values > max_num_values();
103  }
size_t max_num_values() const
Maximum number of values which can be stored in this array.
Definition: IArray.h:58

◆ push_back()

bool push_back ( const T &  val)
inline

Append the passed argument to the end of the array if there is room.

Parameters
[in]valValue to add to the array.
Returns
True if the point was successfully added to the array. False if the array is full and the point couldn't be added.

Definition at line 78 of file IArray.h.

79  {
80  ARM_COMPUTE_ERROR_ON(0 == _max_size);
81  if(_num_values >= max_num_values())
82  {
83  _num_values = max_num_values() + 1;
84  return false;
85  }
86  at(_num_values) = val;
87  _num_values++;
88  return true;
89  }
#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
size_t max_num_values() const
Maximum number of values which can be stored in this array.
Definition: IArray.h:58
virtual T & at(size_t index) const
Reference to the element of the array located at the given index.
Definition: IArray.h:117

Referenced by CPPSortEuclideanDistanceKernel::run(), and NEHOGDetectorKernel::run().

◆ resize()

void resize ( size_t  num)
inline

Resizes the array to contain "num" elements.

If "num" is smaller than the maximum array size, the content is reduced to its first "num" elements, "num" elements can't be bigger than the maximum number of values which can be stored in this array.

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

Definition at line 128 of file IArray.h.

129  {
131  _num_values = num;
132  };
#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
size_t max_num_values() const
Maximum number of values which can be stored in this array.
Definition: IArray.h:58

Referenced by NEOpticalFlow::configure(), CLOpticalFlow::configure(), CPPDetectionWindowNonMaximaSuppressionKernel::run(), CLFastCorners::run(), CLHOGDetector::run(), and CLMinMaxLocation::run().


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