Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::RunningAverage Class Reference

#include <running_stat.h>

Public Member Functions

 RunningAverage (int window_size=1)
 ################## Implementations below #####################
 
 RunningAverage (const RunningAverage &)=delete
 This type is neither copyable nor movable.
 
RunningAverageoperator= (const RunningAverage &)=delete
 
void Reset (int window_size)
 
void Add (int value)
 Adds the next integer of the stream.
 
double GlobalAverage () const
 
double WindowAverage () const
 
bool IsWindowFull () const
 
void ClearWindow ()
 Clears the current window.
 

Detailed Description

Simple class to compute the average over a fixed size window of an integer stream.

Definition at line 27 of file running_stat.h.

Constructor & Destructor Documentation

◆ RunningAverage() [1/2]

operations_research::RunningAverage::RunningAverage ( int window_size = 1)
inlineexplicit

################## Implementations below #####################

Initialize the class with the maximum window size. It must be positive (this is CHECKed).

Definition at line 101 of file running_stat.h.

◆ RunningAverage() [2/2]

operations_research::RunningAverage::RunningAverage ( const RunningAverage & )
delete

This type is neither copyable nor movable.

Member Function Documentation

◆ Add()

void operations_research::RunningAverage::Add ( int value)
inline

Adds the next integer of the stream.

Definition at line 116 of file running_stat.h.

◆ ClearWindow()

void operations_research::RunningAverage::ClearWindow ( )
inline

Clears the current window.

Definition at line 136 of file running_stat.h.

◆ GlobalAverage()

double operations_research::RunningAverage::GlobalAverage ( ) const
inline

Returns the average of all the values added so far or zero if no values where added.

Definition at line 127 of file running_stat.h.

◆ IsWindowFull()

bool operations_research::RunningAverage::IsWindowFull ( ) const
inline

Returns true iff the current window size is equal to the one specified in the constructor.

Definition at line 141 of file running_stat.h.

◆ operator=()

RunningAverage & operations_research::RunningAverage::operator= ( const RunningAverage & )
delete

◆ Reset()

void operations_research::RunningAverage::Reset ( int window_size)
inline

Resets the class to the exact same state as if it was just constructed with the given window size.

Definition at line 109 of file running_stat.h.

◆ WindowAverage()

double operations_research::RunningAverage::WindowAverage ( ) const
inline

Returns the average of the values in the current window or zero if the current window is empty.

Definition at line 131 of file running_stat.h.


The documentation for this class was generated from the following file: