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:
parent
46cd1c0c76
commit
8ee09f278f
1 changed files with 14 additions and 0 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue