Пример #1
0
        private void Uncover(DataObject headerColumn)
        {
            foreach (var row in EnumerateNodes(headerColumn, o => o.Up))
            {
                foreach (var column in EnumerateNodes(row, o => o.Left))
                {
                    column.Down.Up = column;
                    column.Up.Down = column;
                    column.Header.Size++;
                }
            }

            headerColumn.Right.Left = headerColumn;
            headerColumn.Left.Right = headerColumn;
        }
Пример #2
0
        private void InsertDoublyLinkedNode(DataObject left, ColumnObject up, DataObject node)
        {
            node.InsertHorizontalNode(left.Left, left);
            node.InsertVerticalNode(up.Up, up);

            node.Header = up;
            node.Header.Size++;
        }
Пример #3
0
        private void CreateConstraints(uint matrixRow, uint[] matrixColumns, uint row, uint column, uint value)
        {
            DataObject left = null;
            foreach (var matrixColumn in matrixColumns)
            {
                var node = new DataObject
                {
                    Row = row,
                    Column = column,
                    Value = ++value
                };

                if (left == null)
                {
                    left = node;
                }

                var up = _columnHeaders[matrixColumn];
                _constraintMatrix[matrixRow, matrixColumn] = node;

                InsertDoublyLinkedNode(left, up, node);
            }
        }
Пример #4
0
 private IEnumerable<DataObject> EnumerateNodes(DataObject start, Func<DataObject, DataObject> function)
 {
     var node = start;
     while ((node = function(node)) != start)
     {
         yield return node;
     }
 }
Пример #5
0
        private void Cover(DataObject headerColumn)
        {
            headerColumn.Right.Left = headerColumn.Left;
            headerColumn.Left.Right = headerColumn.Right;

            foreach (var row in EnumerateNodes(headerColumn, o => o.Down))
            {
                foreach (var column in EnumerateNodes(row, o => o.Right))
                {
                    column.Down.Up = column.Up;
                    column.Up.Down = column.Down;
                    column.Header.Size--;
                }
            }
        }