示例#1
0
        private void InitializeSubsets()
        {
            if (!initialized)
            {
                rows   = new Subset[this.length];
                cols   = new Subset[this.length];
                blocks = new Subset[this.length];

                for (int x = 0; x < this.length; ++x)
                {
                    cols[x] = new Subset(this.length);
                    for (int y = 0; y < this.length; ++y)
                    {
                        if (rows[y] == null)
                        {
                            rows[y] = new Subset(this.length);
                        }

                        int block     = (x / this.subLength) + ((y / this.subLength) * this.subLength);
                        int blockCell = (x % this.subLength) + ((y % this.subLength) * this.subLength);

                        if (blocks[block] == null)
                        {
                            blocks[block] = new Subset(this.length);
                        }

                        rows[y].Cells[x] = cells[x, y];
                        cols[x].Cells[y] = cells[x, y];
                        blocks[block].Cells[blockCell] = cells[x, y];
                    }
                }

                foreach (var row in this.rows)
                {
                    row.RegisterCells();
                }
                foreach (var col in this.cols)
                {
                    col.RegisterCells();
                }
                foreach (var block in this.blocks)
                {
                    block.RegisterCells();
                }

                initialized = true;
            }
        }
示例#2
0
 public Subset(Subset other)
 {
     this._Length = other.Length;
     this._Cells  = other.Cells.Select(c => new ValueBlock(c)).ToArray();
 }