forEach top-level property
List<double> Function(List<double> a, int? stride, int? offset, int? count, dynamic fn, dynamic arg)
forEach
final
Perform some operation over an array of vec4s.
@param {Array} a the array of vectors to iterate over
@param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed
@param {Number} offset Number of elements to skip at the beginning of the array
@param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array
@param {Function} fn Function to call for each vector in the array
@param {Object} arg
additional argument to pass to fn
@returns {Array} a
@function
Implementation
final forEach = (() {
final vec = create();
return (List<double> a, int? stride, int? offset, int? count, fn, arg) {
int i, l;
stride ??= 4;
offset ??= 0;
if (count != null) {
l = math.min(count * stride + offset, a.length);
} else {
l = a.length;
}
for (i = offset; i < l; i += stride) {
vec[0] = a[i];
vec[1] = a[i + 1];
vec[2] = a[i + 2];
vec[3] = a[i + 3];
fn(vec, vec, arg);
a[i] = vec[0];
a[i + 1] = vec[1];
a[i + 2] = vec[2];
a[i + 3] = vec[3];
}
return a;
};
})();