日期:2009-03-26  浏览次数:20444 次

file: CardCollection.cs

using System;
using System.Diagnostics ;


namespace Bigeagle.Games.Cards
{
    /// <summary>
    /// 牌集合
    /// <br>Author: bigeagle</br>
    /// <br>Date: 2002/4/19</br>
    /// <br>History: 2002/4/19</br>
    /// </summary>
    public class CardCollection : System.Collections.ICollection
    {
        #region 成员变量

        /// <summary>
        /// 牌数组
        /// </summary>
        protected Card[] m_arrCards ;

        /// <summary>
        /// 大小
        /// </summary>
        protected int m_intSize ;

        /// <summary>
        /// 最后一个有效元素的索引
        /// </summary>
        protected int m_intCapacity  ;

        #endregion

        #region 构造函数

        /// <summary>
        /// 构造函数
        /// </summary>
        public CardCollection()
        {
            this.m_arrCards = new Card[16] ;
            this.m_intCapacity = -1 ;
            this.m_intSize = 0 ;
        }
        #endregion

        #region 类方法
        /// <summary>
        /// 重新设置容量
        /// </summary>
        /// <param name="capacity">要设置的容量</param>
        private void SetCapacity(int capacity)
        {
            Card[] cards = new Card[capacity];
            if (this.m_intSize > 0)
            {
                if (this.m_intCapacity > 0)
                {
                    Array.Copy(this.m_arrCards , 0 , cards , 0, this.m_intSize) ;
               &n