getRangeArray method
Return an array given an index interval
start
: start index close intervalend
: end index open intervalstep
: optional, step between samplesreverse
: optional, return a reversed array
Examples
var var list = ArrayComplex([
Complex(real: 3.0, imaginary: 4.0),
Complex(real: 3.0, imaginary: 4.0),
Complex(real: 3.0, imaginary: 4.0)]);
var b = list.getRangeArray(0, 1);
print(b)
/* output:
ArrayComplex([
Complex(real: 3.0, imaginary: 4.0)
]);
*/
Implementation
ArrayComplex getRangeArray(int start, int end,
{int step = 1, bool reverse = false}) {
var b = ArrayComplex.empty();
for (var i = start; i < end; i += step) {
b.add(this[i]);
}
if (reverse) {
b = ArrayComplex(b.reversed.toList());
}
return b;
}