void BuildSkeleton(int gridDimension)
        {
            int r, c;
            r = Convert.ToInt32(Math.Pow(gridDimension, 3));
            c = Convert.ToInt32(Math.Pow(gridDimension, 2) * 4);

            Columns = new Header[c];
            Rows = new Node[r];

            // columns
            for (int i = 0; i < c; i++)
            {
                Columns[i] = new Header(i)
                {
                    Left = RootHeader.Left,
                    Right = RootHeader
                };
                RootHeader.Left.Right = Columns[i];
                RootHeader.Left = Columns[i];
            }

            // rows
            for (int i = 0; i < r; i++)
            {
                Rows[i] = new Node();
            }
        }
Beispiel #2
0
 public Node(int row, Header head)
 {
     this.left = this;
     this.right = this;
     this.up = this;
     this.down = this;
     this.row = row;
     this.head = head;
 }
        void UncoverColumn(Header c)
        {
            // nodes plugging
            Node i = c.Up;
            Node j = null;
            while (i != c)
            {
                j = i.Left;
                while (j != i)
                {
                    j.Up.Down = j;
                    j.Down.Up = j;
                    j.Head.Size++;
                    j = j.Left;
                }
                i = i.Up;
            }

            // header plugging
            c.Left.Right = c;
            c.Right.Left = c;
        }
        void CoverColumn(Header header)
        {
            // header unplugging
            header.Left.Right = header.Right;
            header.Right.Left = header.Left;

            // nodes unplugging
            Node i = header.Down;
            Node j = null;
            while (i != header)
            {
                j = i.Right;
                while (j != i)
                {
                    j.Up.Down = j.Down;
                    j.Down.Up = j.Up;
                    j.Head.Size--;
                    j = j.Right;
                }
                i = i.Down;
            }
        }