[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using std::xxx routines from <algorithm>?
From: |
Rik |
Subject: |
Using std::xxx routines from <algorithm>? |
Date: |
Sat, 15 Apr 2017 14:51:22 -0700 |
jwe,
I noticed in your last cset:
for (octave_idx_type i = 0; i < nz; i++)
r[i] = 0;
Would it be clearer to start using routines from std::algorithm for fills
and copies?
In this case one could write something like this:
std::fill_n (r, nz, 0);
There are loads of other simple loops that might be replaced. Here is one
from dim-vector.h
octave_idx_type *clonerep (void)
{
int l = ndims ();
octave_idx_type* r = newrep (l);
for (int i = 0; i < l; i++)
r[i] = rep[i];
return r;
}
where the replacement might be
std::copy_n (rep, l, r);
Just an idea,
Rik
- Using std::xxx routines from <algorithm>?,
Rik <=