๐ AtIndex
Returns the requested element at the absolute position of the array.
If the requested index exceed the array size, it will return a 0.
๐ Syntaxโ
TypeOfArray at_index(size_t index)
๐ฎ Exampleโ
// This will create an MovingAverage of size 4 and int type
DataTomeMvAvg<int> intAverage(4);
// Array.atIndex(): 1 0 0 0
intAverage.push(1);
// Array.atIndex(): 1 2 0 0
intAverage.push(2);
// Array.atIndex(): 1 2 3 0
intAverage.push(3);
// Array.atIndex(): 1 2 3 4
intAverage.push(4)
// return 1
intAverage.at_index(0);
โฑ Complexityโ
Constant (O(1)).