MCPcopy Create free account
hub / github.com/Tencent/UnLua / Shuffle

Method Shuffle

Plugins/UnLua/Source/UnLua/Private/Containers/LuaArray.h:322–333  ·  view source on GitHub ↗

* Shuffle the elements */

Source from the content-addressed store, hash-verified

320 * Shuffle the elements
321 */
322 FORCEINLINE void Shuffle()
323 {
324 int32 LastIndex = Num() - 1;
325 for (int32 i = 0; i <= LastIndex; ++i)
326 {
327 int32 Index = FMath::RandRange(i, LastIndex);
328 if (i != Index)
329 {
330 ScriptArray->SwapMemory(i, Index, ElementSize);
331 }
332 }
333 }
334
335 /**
336 * Append another array

Callers 1

TArray_ShuffleFunction · 0.80

Calls 1

NumFunction · 0.85

Tested by

no test coverage detected