Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
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
8
namespace
AlgoImpl
9
{
10
template
<
typename
T>
11
int32
RotateInternal
(T* First, int32 Num, int32 Count)
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
48
namespace
Algo
49
{
50
/**
51
* Rotates a given amount of elements from the front of the range to the end of the range.
52
*
53
* @param Range The range to rotate.
54
* @param Num The number of elements to rotate from the front of the range.
55
*
56
* @return The new index of the element that was previously at the start of the range.
57
*/
58
template
<
typename
RangeType>
59
FORCEINLINE
int32
Rotate
(RangeType& Range, int32 Count)
60
{
61
return
AlgoImpl
::
RotateInternal
(
GetData
(
Range
),
GetNum
(
Range
),
Count
);
62
}
63
}
FORCEINLINE
#define FORCEINLINE
Definition
Platform.h:644
Algo
Definition
Heapify.h:12
Algo::Rotate
FORCEINLINE int32 Rotate(RangeType &Range, int32 Count)
Definition
Rotate.h:59
AlgoImpl
Definition
IsHeap.h:12
AlgoImpl::RotateInternal
int32 RotateInternal(T *First, int32 Num, int32 Count)
Definition
Rotate.h:11
Downloads
ArkServerAPI_NEW
ASA
AsaApi
AsaApi
Core
Public
API
UE
Algo
Rotate.h
Generated by
1.10.0