UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
StatisticalFloat.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
8
9// Used to measure a distribution
10template <typename T>
12{
13public:
15 : MinValue()
16 , MaxValue()
17 , Accumulator()
18 , NumSamples()
19 {
20 }
21
23 {
24 if (NumSamples == 0)
25 {
26 MinValue = MaxValue = Value;
27 }
28 else
29 {
30 MinValue = FMath::Min(MinValue, Value);
31 MaxValue = FMath::Max(MaxValue, Value);
32 }
33 Accumulator += Value;
34 ++NumSamples;
35 }
36
37 [[nodiscard]] T GetMinValue() const
38 {
39 return MinValue;
40 }
41
42 [[nodiscard]] T GetMaxValue() const
43 {
44 return MaxValue;
45 }
46
47 [[nodiscard]] T GetAvgValue() const
48 {
49 return (NumSamples > 0) ? (Accumulator / (double)NumSamples) : T();
50 }
51
53 {
54 return NumSamples;
55 }
56
57private:
58 T MinValue;
59 T MaxValue;
60 T Accumulator;
61 int32 NumSamples;
62};
63
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
FStatisticalValue< double > FStatisticalFloat
Definition StatisticalFloat.h:64
Definition StatisticalFloat.h:12
void AddSample(T Value)
Definition StatisticalFloat.h:22
T GetMinValue() const
Definition StatisticalFloat.h:37
FStatisticalValue()
Definition StatisticalFloat.h:14
T GetMaxValue() const
Definition StatisticalFloat.h:42
T GetAvgValue() const
Definition StatisticalFloat.h:47
int32 GetCount() const
Definition StatisticalFloat.h:52