mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #1439 from FlightControl-Master/wingthor_fixes
Added a table shuffler using Fisher Yeates algorithm in Utilities/Uti…
This commit is contained in:
commit
83bcd55a7a
@ -1500,4 +1500,24 @@ function UTILS.GetOSTime()
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
--- Shuffle a table accoring to Fisher Yeates algorithm
|
||||
--@param #table table to be shuffled
|
||||
--@return #table
|
||||
function UTILS.ShuffleTable(t)
|
||||
if t == nil or type(t) ~= "table" then
|
||||
BASE:I("Error in ShuffleTable: Missing or wrong tyåe of Argument")
|
||||
return
|
||||
end
|
||||
math.random()
|
||||
math.random()
|
||||
math.random()
|
||||
local TempTable = {}
|
||||
for i = 1, #t do
|
||||
local r = math.random(1,#t)
|
||||
TempTable[i] = t[r]
|
||||
table.remove(t,r)
|
||||
end
|
||||
return TempTable
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user