コード例 #1
0
ファイル: KeyboadActionList.cs プロジェクト: uvbs/FullSource
        /// <summary>
        /// Remove a specified item from the list
        /// </summary>
        /// <param name="item">Item to remove</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);
        }
コード例 #2
0
ファイル: KeyboadActionList.cs プロジェクト: uvbs/FullSource
 /// <summary>
 /// Returns the index of a specified KeyboardAction
 /// </summary>
 /// <param name="item">KeyboardAction to find</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);
 }
コード例 #3
0
ファイル: KeyboadActionList.cs プロジェクト: uvbs/FullSource
        /// <summary>
        /// Adds a KeyboardAction to the list
        /// </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++);
        }
コード例 #4
0
ファイル: KeyboadActionList.cs プロジェクト: uvbs/FullSource
        /// <summary>
        /// Inserts a KeyboardAction at a specified position
        /// </summary>
        /// <param name="position">Insert position</param>
        /// <param name="item">Item to insert</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++;
        }
コード例 #5
0
ファイル: KeyboadActionList.cs プロジェクト: uvbs/FullSource
 /// <summary>
 /// Returns true if the list contains the specified KeyboardAction
 /// </summary>
 /// <param name="item">KeyboardAction to find</param>
 /// <returns></returns>
 public bool Contains(T item)
 {
     return((IndexOf(item) == -1) ? false : true);
 }
コード例 #6
0
		/// <summary>
		/// Copies this list into another KeyboardrActionList
		/// </summary>
		/// <param name="array">Target list</param>
		public void CopyTo(T[] array)
		{
			this.CopyTo(array, 0);
		}
コード例 #7
0
		/// <summary>
		/// Copies this list into another KeyboardrActionList
		/// </summary>
		/// <param name="array">Target list</param>
		/// <param name="start">Start index</param>
		public void CopyTo(T[] 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);
		}
コード例 #8
0
		/// <summary>
		/// Add the content of a KeyboardAction array to this list
		/// </summary>
		/// <param name="array"></param>
		public void AddRange(T[] array)
		{
			// for (int i=0; i < array.Length; ++i) Add(array[i]);

			++m_version;

			Capacity += array.Length;
			Array.Copy(array, 0, this.m_array, m_count, array.Length);
			m_count += array.Length;
		}
コード例 #9
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="array"></param>
		public KeyboardActionList(T[] array)
		{
			AddRange(array);
		}
コード例 #10
0
		/// <summary>
		/// Remove a specified item from the list
		/// </summary>
		/// <param name="item">Item to remove</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);
		}
コード例 #11
0
		/// <summary>
		/// Inserts a KeyboardAction at a specified position
		/// </summary>
		/// <param name="position">Insert position</param>
		/// <param name="item">Item to insert</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++;
		}
コード例 #12
0
		/// <summary>
		/// Returns the index of a specified KeyboardAction
		/// </summary>
		/// <param name="item">KeyboardAction to find</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;
		}
コード例 #13
0
		/// <summary>
		/// Returns true if the list contains the specified KeyboardAction
		/// </summary>
		/// <param name="item">KeyboardAction to find</param>
		/// <returns></returns>
		public bool Contains(T item)
		{
			return ((IndexOf(item) == -1) ? false : true);
		}
コード例 #14
0
		/// <summary>
		/// Adds a KeyboardAction to the list
		/// </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++;
		}