Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
RandomShuffle.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Math/UnrealMathUtility.h"
6#include "Templates/UnrealTemplate.h"
7
8namespace Algo
9{
10 /**
11 * Randomly shuffle a range of elements.
12 *
13 * @param Range Any contiguous container.
14 */
15 template <typename RangeType>
16 void RandomShuffle(RangeType& Range)
17 {
18 auto Data = GetData(Range);
19
20 using SizeType = decltype(GetNum(Range));
21 const SizeType Num = GetNum(Range);
22
23 for (SizeType Index = 0; Index < Num - 1; ++Index)
24 {
25 // Get a random integer in [Index, Num)
27 if (RandomIndex != Index)
28 {
30 }
31 }
32 }
33}
Definition Heapify.h:12
void RandomShuffle(RangeType &Range)