Ejemplo n.º 1
0
        /// <summary> Strongly typed implementation of <see cref="ICollection{T}.CopyTo"/>. </summary>
        /// <param name="darray"> The <see cref="DynamicArray{T}"/> where to copy the values. </param>
        /// <param name="indexes">The zero-based indexes offset in darray at which copying begins. </param>
        public void CopyTo(DynamicArray <T> darray, params int[] indexes)
        {
            DynamicArrayEnumerator <T> enumerator = this.GetEnumerator();

            foreach (T elt in enumerator)
            {
                darray.SetValue(elt, IndexesHelper.Add(enumerator.GetIndexes(), indexes));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Copies the elements of the <see cref="DynamicArray{T}"/> to a new array with rank
        /// <see cref="DynamicArray{T}.Rank"/> and with lengthes equal to <see cref="DynamicArray{T}"/> counts.
        /// </summary>
        /// <returns> An array containing copies of the elements of the<see cref="DynamicArray{T}"/>. </returns>
        public Array ToArray()
        {
            Array data = Array.CreateInstance(typeof(T), this.counts);
            DynamicArrayEnumerator <T> dynenum = new DynamicArrayEnumerator <T>(this);

            foreach (T elt in dynenum)
            {
                data.SetValue(elt, dynenum.GetIndexes());
            }

            return(data);
        }