mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-30 18:47:08 -05:00
30 lines
773 B
C#
30 lines
773 B
C#
using System;
|
|
|
|
namespace VrmLib
|
|
{
|
|
public static class ArraySegmentExtensions
|
|
{
|
|
public static ArraySegment<T> Slice<T>(this ArraySegment<T> self, int start, int length)
|
|
{
|
|
if (start + length > self.Count)
|
|
{
|
|
throw new ArgumentOutOfRangeException();
|
|
}
|
|
return new ArraySegment<T>(
|
|
self.Array,
|
|
self.Offset + start,
|
|
length
|
|
);
|
|
}
|
|
|
|
public static ArraySegment<T> Slice<T>(this ArraySegment<T> self, int start)
|
|
{
|
|
if (start > self.Count)
|
|
{
|
|
throw new ArgumentOutOfRangeException();
|
|
}
|
|
return self.Slice(start, self.Count - start);
|
|
}
|
|
}
|
|
}
|