public CopyTo ( object source, uint start, int length ) : void | ||
source | object | The sparse array to copy. |
start | uint | The zero-based index at which copying begins. |
length | int | The number of elements to copy. |
return | void |
public void CopyTo(object[] source, uint start, int length)
{
int sourceOffset = 0;
do
{
// Get a reference to the array to copy to.
object[] dest = FindOrCreateArray(start, writeAccess: true);
int destOffset = (int)(start & NodeMask);
// Copy as much as possible.
int copyLength = Math.Min(length - sourceOffset, dest.Length - destOffset);
Array.Copy(source, sourceOffset, dest, destOffset, copyLength);
start += (uint)copyLength;
sourceOffset += copyLength;
} while (sourceOffset < length);
}
SparseArray::CopyTo ( |
/// <summary> /// Creates a sparse array from the given dense array. /// </summary> /// <param name="array"> The array to copy items from. </param> /// <param name="length"> The number of items to copy. </param> /// <returns> A new sparse array containing the items from the given array. </returns> public static SparseArray FromDenseArray(object[] array, int length) { if (array == null) throw new ArgumentNullException("array"); if (length > array.Length) throw new ArgumentOutOfRangeException("length"); var result = new SparseArray(); result.CopyTo(array, 0, length); return result; }