Aetheria/Assets/Scripts/ServerShared/NIH/LinqFaster/Repeat.cs
hyperion51 c24c155673 Context Menus & Progress Bars
We now have a context menu UI for in-game actions, right click on an item to activate
Database view has a progress bar (finally!)
Data structures for Megacorps and loadouts
Towing task complete? needs testing
2020-05-10 00:16:33 +01:00

46 lines
1.5 KiB
C#

using System.Collections.Generic;
namespace JM.LinqFaster
{
public static partial class LinqFaster
{
// ------------------------ Arrays ---------------------------
/// <summary>
/// Generates a sequence that contains one repeated value.
/// </summary>
/// <param name="element">The value to be repeated.</param>
/// <param name="count">The number of times to repeat the value in the generated sequence.</param>
/// <returns>A sequence that contains a repeated value</returns>
public static T[] RepeatArrayF<T>(T element, int count)
{
var result = new T[count];
for (int i = 0; i < result.Length; i++)
{
result[i] = element;
}
return result;
}
// ------------------------ Lists ---------------------------
/// <summary>
/// Generates a sequence that contains one repeated value.
/// </summary>
/// <param name="element">The value to be repeated.</param>
/// <param name="count">The number of times to repeat the value in the generated sequence.</param>
/// <returns>A sequence that contains a repeated value</returns>
public static List<T> RepeatListF<T>(T element, int count)
{
var result = new List<T>(count);
for (int i = 0; i < count; i++)
{
result.Add(element);
}
return result;
}
}
}