Advanced Chunk Processing Library 0.2.0
A comprehensive C++ library for advanced data chunking strategies and processing operations
Loading...
Searching...
No Matches
chunk_windows::WindowOperations< T > Class Template Reference

#include <chunk_windows.hpp>

Static Public Member Functions

static T moving_average (const std::vector< T > &window)
 
static T moving_max (const std::vector< T > &window)
 
static T moving_median (std::vector< T > window)
 
static T moving_min (const std::vector< T > &window)
 

Detailed Description

template<typename T>
class chunk_windows::WindowOperations< T >

Definition at line 117 of file chunk_windows.hpp.

Member Function Documentation

◆ moving_average()

template<typename T >
static T chunk_windows::WindowOperations< T >::moving_average ( const std::vector< T > &  window)
inlinestatic

Definition at line 119 of file chunk_windows.hpp.

119 {
120 if (window.empty()) {
121 return T{}; // Return default value for empty input
122 }
123 return std::accumulate(window.begin(), window.end(), T{}) / static_cast<T>(window.size());
124 }

◆ moving_max()

template<typename T >
static T chunk_windows::WindowOperations< T >::moving_max ( const std::vector< T > &  window)
inlinestatic

Definition at line 134 of file chunk_windows.hpp.

134 {
135 if (window.empty()) {
136 throw std::invalid_argument("Cannot compute max of empty window");
137 }
138 return *std::max_element(window.begin(), window.end());
139 }

◆ moving_median()

template<typename T >
static T chunk_windows::WindowOperations< T >::moving_median ( std::vector< T >  window)
inlinestatic

Definition at line 126 of file chunk_windows.hpp.

126 {
127 if (window.empty()) {
128 throw std::invalid_argument("Cannot compute median of empty window");
129 }
130 std::sort(window.begin(), window.end());
131 return window[window.size() / 2];
132 }

◆ moving_min()

template<typename T >
static T chunk_windows::WindowOperations< T >::moving_min ( const std::vector< T > &  window)
inlinestatic

Definition at line 141 of file chunk_windows.hpp.

141 {
142 if (window.empty()) {
143 throw std::invalid_argument("Cannot compute min of empty window");
144 }
145 return *std::min_element(window.begin(), window.end());
146 }

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