UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Rotate.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Templates/UnrealTemplate.h" // For GetData, GetNum, Swap
6
7
8namespace AlgoImpl
9{
10 template <typename T>
12 {
13 if (Count == 0)
14 {
15 return Num;
16 }
17
18 if (Count >= Num)
19 {
20 return 0;
21 }
22
23 T* Iter = First;
24 T* Mid = First + Count;
25 T* End = First + Num;
26
27 T* OldMid = Mid;
28 for (;;)
29 {
30 Swap(*Iter++, *Mid++);
31 if (Mid == End)
32 {
33 if (Iter == OldMid)
34 {
35 return Num - Count;
36 }
37
38 Mid = OldMid;
39 }
40 else if (Iter == OldMid)
41 {
42 OldMid = Mid;
43 }
44 }
45 }
46}
47
48namespace Algo
49{
58 template <typename RangeType>
59 UE_REWRITE int32 Rotate(RangeType&& Range, int32 Count)
60 {
61 return AlgoImpl::RotateInternal(GetData(Range), GetNum(Range), Count);
62 }
63}
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define UE_REWRITE
Definition Platform.h:747
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
@ Num
Definition MetalRHIPrivate.h:234
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
Definition BinarySearch.h:10
int32 RotateInternal(T *First, int32 Num, int32 Count)
Definition Rotate.h:11
Definition ParallelSort.h:13