Aetheria/Assets/Scripts/ServerShared/NIH/LinqFaster/Range.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

56 lines
1.8 KiB
C#

using System.Collections.Generic;
namespace JM.LinqFaster
{
public static partial class LinqFaster
{
/// <summary>
/// Generates a sequence of integral numbers within a specified range.
/// </summary>
/// <param name="start">The value of the first integer in the sequence.</param>
/// <param name="count">The number of sequential integers to generate.</param>
/// <returns>A sequence that contains a range of sequential integral numbers.</returns>
public static int[] RangeArrayF(int start, int count)
{
long max = ((long)start) + count - 1;
if (count < 0 || max > int.MaxValue)
{
throw Error.ArgumentOutOfRange("count");
}
int[] result = new int[count];
for (int i = 0; i < result.Length; i++)
{
result[i] = i + start;
}
return result;
}
/// <summary>
/// Generates a sequence of integral numbers within a specified range.
/// </summary>
/// <param name="start">The value of the first integer in the sequence.</param>
/// <param name="count">The number of sequential integers to generate.</param>
/// <returns>A sequence that contains a range of sequential integral numbers.</returns>
public static List<int> RangeListF(int start, int count)
{
long max = ((long)start) + count - 1;
if (count < 0 || max > int.MaxValue)
{
throw Error.ArgumentOutOfRange("count");
}
var result = new List<int>(count);
for (int i = 0; i < count; i++)
{
result.Add(i + start);
}
return result;
}
}
}