Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        public void Remove(T 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);
        }
Example #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public int IndexOf(T item)
 {
     for (int i = 0; i < m_count; ++i)
     {
         if (m_array[i] == (item))
         {
             return(i);
         }
     }
     return(-1);
 }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public int Add(T item)
        {
            if (NeedsGrowth())
            {
                Grow();
            }

            ++m_version;
            m_array[m_count] = item;

            return(m_count++);
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="position"></param>
        /// <param name="item"></param>
        public void Insert(int position, T 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++;
        }
Example #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Contains(T item)
 {
     return((IndexOf(item) == -1) ? false : true);
 }