DotRecastNetSim/src/DotRecast.Core/RcArrayUtils.cs

42 lines
967 B
C#
Raw Normal View History

2023-03-14 08:02:43 +03:00
using System;
2023-03-16 19:09:10 +03:00
namespace DotRecast.Core
{
2023-05-10 16:44:51 +03:00
public static class RcArrayUtils
2023-03-14 08:02:43 +03:00
{
2023-03-16 19:48:49 +03:00
public static T[] CopyOf<T>(T[] source, int startIdx, int length)
2023-03-14 08:02:43 +03:00
{
2023-03-16 19:48:49 +03:00
var deatArr = new T[length];
for (int i = 0; i < length; ++i)
{
deatArr[i] = source[startIdx + i];
}
2023-03-14 08:02:43 +03:00
2023-03-16 19:48:49 +03:00
return deatArr;
}
2023-03-14 08:02:43 +03:00
2023-10-01 12:50:04 +03:00
public static T[] CopyOf<T>(T[] source, long length)
2023-03-14 08:02:43 +03:00
{
2023-03-16 19:48:49 +03:00
var deatArr = new T[length];
var count = Math.Max(0, Math.Min(source.Length, length));
for (int i = 0; i < count; ++i)
{
deatArr[i] = source[i];
}
return deatArr;
2023-03-14 08:02:43 +03:00
}
2023-03-16 19:48:49 +03:00
public static T[][] Of<T>(int len1, int len2)
2023-03-14 08:02:43 +03:00
{
2023-03-16 19:48:49 +03:00
var temp = new T[len1][];
2023-03-14 08:02:43 +03:00
2023-03-16 19:48:49 +03:00
for (int i = 0; i < len1; ++i)
{
temp[i] = new T[len2];
}
return temp;
}
}
2023-03-14 08:02:43 +03:00
}