Jurassic.Library.SparseArray.CopyTo C# (CSharp) Method

CopyTo() public method

Copies the elements of the sparse array to this sparse array, starting at a particular index. Existing values are overwritten.
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);
        }

Same methods

SparseArray::CopyTo ( SparseArray source, uint start ) : void

Usage Example

コード例 #1
0
ファイル: SparseArray.cs プロジェクト: vipwan/CommunityServer
 /// <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;
 }
All Usage Examples Of Jurassic.Library.SparseArray::CopyTo