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

#include <running_stat.h>

Public Member Functions

 RunningMax (int window_size)
 Takes the size of the running window. The size must be positive.
 
 RunningMax (const RunningMax &)=delete
 This type is neither copyable nor movable.
 
RunningMaxoperator= (const RunningMax &)=delete
 
void Add (Number value)
 Processes a new element from the stream.
 
Number GetCurrentMax ()
 

Detailed Description

template<class Number = double>
class operations_research::RunningMax< Number >

Simple class to efficiently compute the maximum over a fixed size window of a numeric stream. This works in constant average amortized time.

Definition at line 70 of file running_stat.h.

Constructor & Destructor Documentation

◆ RunningMax() [1/2]

template<class Number >
operations_research::RunningMax< Number >::RunningMax ( int window_size)
explicit

Takes the size of the running window. The size must be positive.

Definition at line 146 of file running_stat.h.

◆ RunningMax() [2/2]

template<class Number = double>
operations_research::RunningMax< Number >::RunningMax ( const RunningMax< Number > & )
delete

This type is neither copyable nor movable.

Member Function Documentation

◆ Add()

template<class Number >
void operations_research::RunningMax< Number >::Add ( Number value)

Processes a new element from the stream.

Starting phase until values_ reaches its final size.

Note
last_index_ stays at 0 during this phase.

We are in the steady state.

Note the use of >= instead of > to get the O(1) behavior in presence of many identical values.

We need to recompute the max.

Note
this happens only if value was strictly lower than GetCurrentMax() in the last window_size_ updates.

Definition at line 152 of file running_stat.h.

◆ GetCurrentMax()

template<class Number >
Number operations_research::RunningMax< Number >::GetCurrentMax ( )

Returns the current maximum element in the window. An element must have been added before calling this function.

Definition at line 191 of file running_stat.h.

◆ operator=()

template<class Number = double>
RunningMax & operations_research::RunningMax< Number >::operator= ( const RunningMax< Number > & )
delete

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