fix: Codegens promo items (#1355)
This commit is contained in:
parent
bf6da39176
commit
8e3facc57b
61 changed files with 1430 additions and 1923 deletions
|
|
@ -1036,6 +1036,27 @@ public static class Utility
|
|||
return sampleList;
|
||||
}
|
||||
|
||||
public static void RandomSample<T>(this T[] source, int count, List<T> dest)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var length = source.Length;
|
||||
Span<bool> list = stackalloc bool[length];
|
||||
|
||||
var i = 0;
|
||||
do
|
||||
{
|
||||
var rand = Random(length);
|
||||
if (!(list[rand] && (list[rand] = true)))
|
||||
{
|
||||
dest.Add(source[rand]);
|
||||
}
|
||||
} while (++i < count);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T RandomList<T>(params T[] list) => list.RandomElement();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue