comparison liboctave/array/MArray.cc @ 30169:aedebbc6b765

maint: Convert structs _idxadds_helpe, _idxadda_helper to classes. * MArray.cc: Change type of _idxadds_helper, _idxadda_helper from struct to class. Place member variables in new private section.
author Rik <rik@octave.org>
date Sun, 12 Sep 2021 21:04:44 -0700
parents 14b098a6ba46
children 5933cf5415c4
comparison
equal deleted inserted replaced
30168:4412f57132c4 30169:aedebbc6b765
30 #include "MArray.h" 30 #include "MArray.h"
31 #include "Array-util.h" 31 #include "Array-util.h"
32 #include "lo-error.h" 32 #include "lo-error.h"
33 33
34 template <typename T> 34 template <typename T>
35 struct _idxadds_helper 35 class _idxadds_helper
36 { 36 {
37 public: 37 public:
38 _idxadds_helper (T *a, T v) : array (a), val (v) { } 38 _idxadds_helper (T *a, T v) : m_array (a), m_val (v) { }
39 39
40 void operator () (octave_idx_type i) 40 void operator () (octave_idx_type i)
41 { array[i] += val; } 41 { m_array[i] += m_val; }
42 42
43 //-------- 43 private:
44 44 T *m_array;
45 T *array; 45 T m_val;
46 T val;
47 }; 46 };
48 47
49 template <typename T> 48 template <typename T>
50 struct _idxadda_helper 49 class _idxadda_helper
51 { 50 {
52 public: 51 public:
53 _idxadda_helper (T *a, const T *v) : array (a), vals (v) { } 52 _idxadda_helper (T *a, const T *v) : m_array (a), m_vals (v) { }
54 53
55 void operator () (octave_idx_type i) 54 void operator () (octave_idx_type i)
56 { array[i] += *vals++; } 55 { m_array[i] += *m_vals++; }
57 56
58 //-------- 57 private:
59 58 T *m_array;
60 T *array; 59 const T *m_vals;
61 const T *vals;
62 }; 60 };
63 61
64 template <typename T> 62 template <typename T>
65 void 63 void
66 MArray<T>::idx_add (const octave::idx_vector& idx, T val) 64 MArray<T>::idx_add (const octave::idx_vector& idx, T val)