Skip to main content

โžก๏ธ Front

Returns the first element of the array (the most recent element added).

๐Ÿ“ Syntaxโ€‹

TypeOfArray front()

๐Ÿ”ฎ Exampleโ€‹

// This will create an MovingAverage of size 4 and int type
DataTomeMvAvg<int> intAverage(4);

// Will return 0
intAverage.front();

// Array: 8 0 0 0
intAverage.push(8);

// Will return 8
intAverage.front();

โฑ Complexityโ€‹

Constant (O(1)).