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:
commit
4d949d55ce
1 changed files with 16 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue