UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IsHeap.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/Less.h"
9#include "Templates/UnrealTemplate.h" // For GetData, GetNum
10
11namespace AlgoImpl
12{
24 template <typename RangeValueType, typename IndexType, typename ProjectionType, typename PredicateType>
26 {
27 for (IndexType Index = 1; Index < Num; Index++)
28 {
29 IndexType ParentIndex = HeapGetParentIndex(Index);
30 if (Predicate( Invoke(Projection, Heap[Index]), Invoke(Projection, Heap[ParentIndex]) ))
31 {
32 return false;
33 }
34 }
35
36 return true;
37 }
38}
39
40namespace Algo
41{
49 template <typename RangeType>
50 [[nodiscard]] UE_REWRITE bool IsHeap(const RangeType& Range)
51 {
53 }
54
63 template <typename RangeType, typename PredicateType>
64 [[nodiscard]] UE_REWRITE bool IsHeap(const RangeType& Range, PredicateType Predicate)
65 {
66 return AlgoImpl::IsHeapInternal(GetData(Range), GetNum(Range), FIdentityFunctor(), MoveTemp(Predicate));
67 }
68
77 template <typename RangeType, typename ProjectionType>
78 [[nodiscard]] UE_REWRITE bool IsHeapBy(const RangeType& Range, ProjectionType Projection)
79 {
81 }
82
92 template <typename RangeType, typename ProjectionType, typename PredicateType>
93 [[nodiscard]] UE_REWRITE bool IsHeapBy(const RangeType& Range, ProjectionType Projection, PredicateType Predicate)
94 {
95 return AlgoImpl::IsHeapInternal(GetData(Range), GetNum(Range), MoveTemp(Projection), MoveTemp(Predicate));
96 }
97}
#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
@ Num
Definition MetalRHIPrivate.h:234
AUTORTFM_INFER constexpr auto Projection(Invocable0Type &&Invocable0, InvocableTypes &&... Invocables)
Definition Projection.h:108
auto GetNum(const TStringConversion< Converter, DefaultConversionSize > &Conversion) -> decltype(Conversion.Length())
Definition StringConv.h:808
auto GetData(const TStringConversion< Converter, DefaultConversionSize > &Conversion) -> decltype(Conversion.Get())
Definition StringConv.h:802
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition BinarySearch.h:10
bool IsHeapInternal(const RangeValueType *Heap, IndexType Num, ProjectionType Projection, PredicateType Predicate)
Definition IsHeap.h:25
FORCEINLINE IndexType HeapGetParentIndex(IndexType Index)
Definition BinaryHeap.h:44
Definition ParallelSort.h:13
UE_REWRITE bool IsHeapBy(const RangeType &Range, ProjectionType Projection)
Definition IsHeap.h:78
UE_REWRITE bool IsHeap(const RangeType &Range)
Definition IsHeap.h:50
U16 Index
Definition radfft.cpp:71
Definition IdentityFunctor.h:11
Definition Less.h:19