UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Count.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"
6
7namespace Algo
8{
15 template <typename InT, typename ValueT>
17 {
18 SIZE_T Result = 0;
19 for (const auto& Value : Input)
20 {
21 if (Value == InValue)
22 {
23 ++Result;
24 }
25 }
26 return Result;
27 }
28
35 template <typename InT, typename PredicateT>
36 [[nodiscard]] SIZE_T CountIf(const InT& Input, PredicateT Predicate)
37 {
38 SIZE_T Result = 0;
39 for (const auto& Value : Input)
40 {
41 if (Invoke(Predicate, Value))
42 {
43 ++Result;
44 }
45 }
46 return Result;
47 }
48
56 template <typename InT, typename ValueT, typename ProjectionT>
58 {
59 SIZE_T Result = 0;
60 for (const auto& Value : Input)
61 {
62 if (Invoke(Proj, Value) == InValue)
63 {
64 ++Result;
65 }
66 }
67 return Result;
68 }
69}
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
AUTORTFM_INFER UE_FORCEINLINE_HINT constexpr auto Invoke(FuncType &&Func, ArgTypes &&... Args) -> decltype(((FuncType &&) Func)((ArgTypes &&) Args...))
Definition Invoke.h:44
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition ParallelSort.h:13
SIZE_T CountBy(const InT &Input, const ValueT &InValue, ProjectionT Proj)
Definition Count.h:57
SIZE_T CountIf(const InT &Input, PredicateT Predicate)
Definition Count.h:36