Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public int IndexOf(UndoBlock item)
 {
     for (int i = 0; i < m_count; ++i)
     {
         if (m_array[i] == (item))
         {
             return(i);
         }
     }
     return(-1);
 }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        public void Remove(UndoBlock item)
        {
            int index = IndexOf(item);

            if (index < 0)
            {
                throw new ArgumentException(
                          "Cannot remove the specified item because it was not found in the specified Collection.");
            }

            RemoveAt(index);
        }
Пример #3
0
        // Operations (type-safe IList)

        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public int Add(UndoBlock item)
        {
            if (NeedsGrowth())
            {
                Grow();
            }

            ++m_version;
            m_array[m_count] = item;

            return(m_count++);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="position"></param>
        /// <param name="item"></param>
        public void Insert(int position, UndoBlock item)
        {
            ValidateIndex(position, true); // throws

            if (NeedsGrowth())
            {
                Grow();
            }

            ++m_version;
            // for (int i=m_count; i > position; --i) m_array[i] = m_array[i-1];
            Array.Copy(m_array, position, m_array, position + 1, m_count - position);

            m_array[position] = item;
            m_count++;
        }
Пример #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Contains(UndoBlock item)
 {
     return((IndexOf(item) == -1) ? false : true);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        public void Remove(UndoBlock item)
        {
            int index = IndexOf(item);
            if (index < 0)
                throw new ArgumentException(
                    "Cannot remove the specified item because it was not found in the specified Collection.");

            RemoveAt(index);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="array"></param>
 public UndoBlockCollection(UndoBlock[] array)
 {
     AddRange(array);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public int IndexOf(UndoBlock item)
 {
     for (int i = 0; i < m_count; ++i)
         if (m_array[i] == (item))
             return i;
     return - 1;
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="position"></param>
        /// <param name="item"></param>
        public void Insert(int position, UndoBlock item)
        {
            ValidateIndex(position, true); // throws

            if (NeedsGrowth())
                Grow();

            ++m_version;
            // for (int i=m_count; i > position; --i) m_array[i] = m_array[i-1];
            Array.Copy(m_array, position, m_array, position + 1, m_count - position);

            m_array[position] = item;
            m_count++;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="array"></param>
        /// <param name="start"></param>
        public void CopyTo(UndoBlock[] array, int start)
        {
            if (m_count > array.GetUpperBound(0) + 1 - start)
                throw new ArgumentException(
                    "Destination array was not long enough.");

            // for (int i=0; i < m_count; ++i) array[start+i] = m_array[i];
            Array.Copy(m_array, 0, array, start, m_count);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="array"></param>
 public void CopyTo(UndoBlock[] array)
 {
     CopyTo(array, 0);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Contains(UndoBlock item)
 {
     return ((IndexOf(item) == - 1) ? false : true);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="array"></param>
        public void AddRange(UndoBlock[] array)
        {
            // for (int i=0; i < array.Length; ++i) Add(array[i]);

            ++m_version;

            Capacity += array.Length;
            Array.Copy(array, 0, m_array, m_count, array.Length);
            m_count += array.Length;
        }
        // Operations (type-safe IList)
        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public int Add(UndoBlock item)
        {
            if (NeedsGrowth())
                Grow();

            ++m_version;
            m_array[m_count] = item;

            return m_count++;
        }