# HG changeset patch # User Rik # Date 1362356541 28800 # Node ID b4a6895a9863320947bbc1b2de75e9006fbc1901 # Parent e810e7d941a1b2d182477fd2a6612af3ebd55043 Use proper OO-class for __rangeidx_helper(). * liboctave/array/Range.cc(__rangeidx_helper): Make __rangeidx_helper a class, instead of a struct, for better visibility into what it does. diff --git a/liboctave/array/Range.cc b/liboctave/array/Range.cc --- a/liboctave/array/Range.cc +++ b/liboctave/array/Range.cc @@ -123,13 +123,11 @@ #endif } -// Pseudo-class used for idx_vector.loop () function call -struct _rangeidx_helper +// Helper class used solely for idx_vector.loop () function call +class __rangeidx_helper { - double *array, base, inc, limit; - octave_idx_type nmax; - - _rangeidx_helper (double *a, double b, double i, double l, octave_idx_type n) + public: + __rangeidx_helper (double *a, double b, double i, double l, octave_idx_type n) : array (a), base (b), inc (i), limit (l), nmax (n-1) { } void operator () (octave_idx_type i) @@ -141,13 +139,18 @@ else { double end = base + i * inc; - if ((inc > 0 && end >= limit) - || (inc < 0 && end <= limit)) + if ((inc > 0 && end >= limit) || (inc < 0 && end <= limit)) *array++ = limit; else *array++ = end; } } + + private: + + double *array, base, inc, limit; + octave_idx_type nmax; + }; Array @@ -175,15 +178,17 @@ retval.clear (rd); - // idx_vector loop across all values in i, executing _rangeidx_helper (i) foreach i - i.loop (n, _rangeidx_helper (retval.fortran_vec (), - rng_base, rng_inc, rng_limit, rng_nelem)); + // idx_vector loop across all values in i, + // executing __rangeidx_helper (i) for each i + i.loop (n, __rangeidx_helper (retval.fortran_vec (), + rng_base, rng_inc, rng_limit, rng_nelem)); } return retval; } // NOTE: max and min only return useful values if nelem > 0. +// do_minmax_body() in max.cc avoids calling Range::min/max if nelem == 0. double Range::min (void) const