예제 #1
0
파일: Dlx.cs 프로젝트: SudokuMonster/Sudoku
 /// <summary>
 /// Put the new node into the left side of the old node.
 /// </summary>
 /// <param name="oldNode">The old node.</param>
 /// <param name="newNode">The new node.</param>
 public void PutLeft(DlxNode *oldNode, DlxNode *newNode)
 {
     newNode->Left        = oldNode->Left;
     newNode->Right       = oldNode;
     oldNode->Left->Right = newNode;
     oldNode->Left        = newNode;
 }
예제 #2
0
파일: Dlx.cs 프로젝트: SudokuMonster/Sudoku
 /// <summary>
 /// Put the new node into the up side of the old node.
 /// </summary>
 /// <param name="oldNode">The old node.</param>
 /// <param name="newNode">The new node.</param>
 public void PutUp(DlxNode *oldNode, DlxNode *newNode)
 {
     // If the old node is the head node, we should insert the new node into the tail.
     // However, to be honest, the relative position between the old node and the new node
     // is unnecessary, because we determine the position without using those two nodes.
     newNode->Up       = oldNode->Up;
     newNode->Down     = oldNode;
     oldNode->Up->Down = newNode;
     oldNode->Up       = newNode;
     oldNode->Size++;
     newNode->Column = oldNode;
 }
예제 #3
0
파일: Dlx.cs 프로젝트: SudokuMonster/Sudoku
        /// <summary>
        /// Uncover the specified column.
        /// </summary>
        /// <param name="c">The column.</param>
        public void Uncover(DlxNode *c)
        {
            for (var row = c->Up; row != c; row = row->Up)
            {
                for (var j = row->Left; j != row; j = j->Left)
                {
                    j->Column->Size++;
                    j->Down->Up = j;
                    j->Up->Down = j;
                }
            }

            c->Right->Left = c;
            c->Left->Right = c;
        }
예제 #4
0
파일: Dlx.cs 프로젝트: SudokuMonster/Sudoku
        /// <summary>
        /// Cover the specified column.
        /// </summary>
        /// <param name="c">The column.</param>
        public void Cover(DlxNode *c)
        {
            // Remove the node from the head.
            c->Right->Left = c->Left;
            c->Left->Right = c->Right;

            for (var row = c->Down; row != c; row = row->Down)
            {
                for (var j = row->Right; j != row; j = j->Right)
                {
                    j->Down->Up = j->Up;
                    j->Up->Down = j->Down;
                    j->Column->Size--;
                }
            }
        }