1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-18 16:10:26 +02:00

Array CopyTo for spans

CopyTo, allows copying memory from an array to a span.
This commit is contained in:
Damian Day 2020-05-27 15:36:51 +01:00
parent 46cd1c0c76
commit 8ee09f278f

View file

@ -268,6 +268,20 @@ namespace System
arrayTo.GetRef(i + dstOffset) = (T2)GetRef(i + srcOffset); arrayTo.GetRef(i + dstOffset) = (T2)GetRef(i + srcOffset);
} }
public void CopyTo(Span<T> destination)
{
Debug.Assert(destination.Length >= mLength);
Internal.MemCpy(destination.Ptr, &GetRef(0), strideof(T) * mLength, alignof(T));
}
public void CopyTo(Span<T> destination, int srcOffset, int length)
{
Debug.Assert(length >= 0);
Debug.Assert((uint)srcOffset + (uint)length <= (uint)mLength);
Debug.Assert((uint)length <= (uint)destination.Length);
Internal.MemCpy(destination.Ptr, &GetRef(srcOffset), strideof(T) * length, alignof(T));
}
public Span<T>.Enumerator GetEnumerator() public Span<T>.Enumerator GetEnumerator()
{ {
return .(this); return .(this);