Пример #1
0
        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();
            }
        }
Пример #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;
 }
Пример #3
0
        void AppendRow(int[] pos, int row)
        {
            Node first = new Node(row)
            {
                Head = Columns[pos[0]],
                Down = Columns[pos[0]],
                Up = Columns[pos[0]].Up
            };
            first.Head.Size++;

            Columns[pos[0]].Up.Down = first;
            Columns[pos[0]].Up = first;
            Rows[row] = first;

            for (int i = 1; i < pos.Length; i++)
            {
                Node next = new Node(row)
                {
                    Left = first.Left,
                    Right = first,
                    Down = Columns[pos[i]],
                    Up = Columns[pos[i]].Up,
                    Head = Columns[pos[i]]
                };

                next.Head.Size++;

                first.Left.Right = next;
                first.Left = next;

                Columns[pos[i]].Up.Down = next;
                Columns[pos[i]].Up = next;
            }
        }