Esempio n. 1
0
        /// <summary>
        /// Creates a shallow copy of a range of elements in the source <see cref="BigArray{T}"/>.
        /// </summary>
        /// <param name="index">The zero-based <see cref="BigArray{T}"/> index at which the range starts.</param>
        /// <param name="count">The number of elements in the range.</param>
        /// <returns></returns>
        public BigArray <T> GetRange(int index, int count)
        {
            if (!this.IsValidRange(index, count))
            {
                throw new ArgumentOutOfRangeException();
            }

            var newArray = new BigArray <T>();

            if (count == 0)
            {
                return(newArray);
            }

            var enumerator = GetEnumerator();

            ((BigArrayEnumerator)enumerator).MoveToIndex(index);
            bool isContinue = true;

            while (isContinue && count != 0)
            {
                newArray.Add(enumerator.Current);

                count--;
                isContinue = enumerator.MoveNext();
            }

            return(newArray);
        }
Esempio n. 2
0
 /// <summary>
 /// Inserts an object at the top of the <see cref="BigStack{T}"/>.
 /// </summary>
 /// <param name="item">The object to push onto the <see cref="BigStack{T}"/>.
 ///  The value can be null for reference types.</param>
 public void Push(T item)
 {
     _array.Add(item);
 }
Esempio n. 3
0
 /// <summary>
 /// Adds an object to the end of the <see cref="BigQueue{T}"/>.
 /// </summary>
 /// <param name="item">The object to add to the <see cref="BigQueue{T}"/>. The value can be null for reference types.</param>
 public void Enqueue(T item)
 {
     _array.Add(item);
 }