1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-04 15:26:00 +02:00

Merge pull request #302 from damianday/Array.CopyTo

Array CopyTo for spans
This commit is contained in:
Brian Fiete 2020-05-28 09:02:39 -07:00 committed by GitHub
commit 4d949d55ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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