Exemple #1
0
        /// <summary>
        /// 把元宝从o点移动到d点
        /// </summary>
        public void MoveCell(int xO, int yO, int xD, int yD)
        {
            int iHashkey = CellHashKey.GetHashCode(xO, yO);
            T   cac;

            if (hashMat.TryGetValue(iHashkey, out cac) == true)
            {
                hashMat.Remove(CellHashKey.GetHashCode(xO, yO));
                hashMat.Add(CellHashKey.GetHashCode(xD, yD), cac);
            }
        }
Exemple #2
0
        public void AddCell(int x, int y, T cell)
        {
            //更新行和列的最大索引
            this.iMaxColumn = x > this.iMaxColumn ? x : this.iMaxColumn;
            this.iMaxRow    = y > this.iMaxRow ? y : this.iMaxRow;

            int iHKey = CellHashKey.GetHashCode(x, y);

            if (!hashMat.ContainsKey(iHKey))
            {
                hashMat.Add(iHKey, cell);
            }
        }
Exemple #3
0
        /// <summary>
        /// 枚举某一行的所有元素
        /// </summary>
        /// <param name="iRow">要遍历的行</param>
        /// <returns></returns>
        public List <T> EnumerateColumn(int iRow)//行在数学欧氏坐标系中,对应y轴,
        {
            List <T> listT = new List <T>();

            for (int x = 0; x < this.iMaxColumn; x++)
            {
                T cac;
                if (hashMat.TryGetValue(CellHashKey.GetHashCode(x, iRow), out cac) == true)
                {
                    listT.Add(cac);
                }
            }
            return(listT);
        }
Exemple #4
0
 public void RemoveCell(int x, int y)
 {
     hashMat.Remove(CellHashKey.GetHashCode(x, y));
 }
Exemple #5
0
 /// <summary>
 /// 判断元胞是否被占用了
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public bool IsCellBlocked(int x, int y)
 {
     return(hashMat.ContainsKey(CellHashKey.GetHashCode(x, y)));
 }