diff --git a/BeefLibs/corlib/src/Collections/List.bf b/BeefLibs/corlib/src/Collections/List.bf index 22fb79d2..4ce06606 100644 --- a/BeefLibs/corlib/src/Collections/List.bf +++ b/BeefLibs/corlib/src/Collections/List.bf @@ -530,6 +530,22 @@ namespace System.Collections span[i] = mItems[i]; } + public void CopyTo(Span array, int arrayIndex) + { + // Delegate rest of error checking to Array.Copy. + for (int i = 0; i < mSize; i++) + array[i + arrayIndex] = mItems[i]; + } + + public void CopyTo(int index, Span array, int arrayIndex, int count) + { + Debug.Assert((uint)index < (uint)mSize); + Debug.Assert((uint)index + (uint)count <= (uint)mSize); + // Delegate rest of error checking to Array.Copy. + for (int i = 0; i < count; i++) + array[i + arrayIndex] = mItems[i + index]; + } + public void CopyTo(T[] array, int arrayIndex) { // Delegate rest of error checking to Array.Copy. diff --git a/BeefLibs/corlib/src/Span.bf b/BeefLibs/corlib/src/Span.bf index 02f88634..c30753df 100644 --- a/BeefLibs/corlib/src/Span.bf +++ b/BeefLibs/corlib/src/Span.bf @@ -294,6 +294,14 @@ namespace System Internal.MemMove(destination.mPtr, mPtr, Internal.GetArraySize(mLength), (int32)alignof(T)); } + public void CopyTo(int index, Span array, int arrayIndex, int count) + { + Debug.Assert((uint)index < (uint)Length); + Debug.Assert((uint)index + (uint)count <= (uint)Length); + for (int i = 0; i < count; i++) + array[i + arrayIndex] = Ptr[i + index]; + } + public Span ToRawData() { return Span((uint8*)mPtr, mLength * sizeof(T));