UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Find.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "Templates/IdentityFunctor.h"
7#include "Templates/Invoke.h"
8#include "Templates/UnrealTemplate.h" // For MoveTemp
9
10namespace AlgoImpl
11{
12 template <typename RangeType, typename ValueType, typename ProjectionType>
13 constexpr typename TRangePointerType<typename TRemoveReference<RangeType>::Type>::Type FindBy(RangeType&& Range, const ValueType& Value, ProjectionType Proj)
14 {
15 for (auto&& Elem : Forward<RangeType>(Range))
16 {
17 if (Invoke(Proj, Elem) == Value)
18 {
19 return &Elem;
20 }
21 }
22
23 return nullptr;
24 }
25
26 template <typename RangeType, typename PredicateType>
28 {
29 for (auto&& Elem : Forward<RangeType>(Range))
30 {
31 if (Invoke(Pred, Elem))
32 {
33 return &Elem;
34 }
35 }
36
37 return nullptr;
38 }
39}
40
41namespace Algo
42{
51 template <typename RangeType, typename ValueType>
52 [[nodiscard]] UE_REWRITE constexpr auto Find(RangeType&& Range, const ValueType& Value)
54 {
56 }
57
67 template <typename RangeType, typename ValueType, typename ProjectionType>
68 [[nodiscard]] UE_REWRITE constexpr auto FindBy(RangeType&& Range, const ValueType& Value, ProjectionType Proj)
70 {
72 }
73
82 template <typename RangeType, typename PredicateType>
83 [[nodiscard]] UE_REWRITE constexpr auto FindByPredicate(RangeType&& Range, PredicateType Pred)
85 {
87 }
88}
#define UE_REWRITE
Definition Platform.h:747
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
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition BinarySearch.h:10
constexpr TRangePointerType< typenameTRemoveReference< RangeType >::Type >::Type FindByPredicate(RangeType &&Range, PredicateType Pred)
Definition Find.h:27
constexpr TRangePointerType< typenameTRemoveReference< RangeType >::Type >::Type FindBy(RangeType &&Range, const ValueType &Value, ProjectionType Proj)
Definition Find.h:13
Definition ParallelSort.h:13
UE_REWRITE constexpr auto FindBy(RangeType &&Range, const ValueType &Value, ProjectionType Proj) -> decltype(AlgoImpl::FindBy(Forward< RangeType >(Range), Value, MoveTemp(Proj)))
Definition Find.h:68
UE_REWRITE constexpr auto FindByPredicate(RangeType &&Range, PredicateType Pred) -> decltype(AlgoImpl::FindByPredicate(Forward< RangeType >(Range), MoveTemp(Pred)))
Definition Find.h:83
Definition RangePointerType.h:14
Definition IdentityFunctor.h:11