当前位置: 首页>>代码示例>>C#>>正文


C# BitSet.IsSubsetOf方法代码示例

本文整理汇总了C#中BitSet.IsSubsetOf方法的典型用法代码示例。如果您正苦于以下问题:C# BitSet.IsSubsetOf方法的具体用法?C# BitSet.IsSubsetOf怎么用?C# BitSet.IsSubsetOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitSet的用法示例。


在下文中一共展示了BitSet.IsSubsetOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Expand

        public static Tree Expand(Tree tree, BitSet parent, int node)
        {
            Tree newTree = new Tree();

            Queue<BitSet> queue = new Queue<BitSet>();
            queue.Enqueue(tree.Root);

            while (queue.Count > 0)
            {
                BitSet set = queue.Dequeue();
                BitSet child;
                if (tree.LeftChild.TryGetValue(set, out child))
                {
                    queue.Enqueue(child);
                }
                if (tree.RightChild.TryGetValue(set, out child))
                {
                    queue.Enqueue(child);
                }
                if (parent.IsSubsetOf(set))
                {
                    set += node;
                }

                newTree.Insert(set);
            }

            newTree.Insert(parent);
            newTree.Insert(newTree.Root * node);

            return newTree;
        }
开发者ID:Miloan,项目名称:BooleanWidth,代码行数:32,代码来源:ReductionRuleHelper.cs

示例2: Insert

        /*************************/
        // Basic operations
        /*************************/
        // Inserting works correctly because we assume that a node that gets newly inserted will not be in the tree already
        // By definition of boolean decompositions this is redundant and the node should be removed from the decomposition tree
        public void Insert(BitSet node)
        {
            if (Parent.ContainsKey(node))
                throw new Exception("This node already exists in the decomposition tree");

            // Check if this is the first node that we add to the collection
            if (Size == 0)
            {
                Root = node;
                _contained.Add(node);
                return;
            }

            // The parent of the node that we are currently insering should be the node X that this node is a subset of, and X is has the highest index so far
            BitSet parent = new BitSet(0, 0);
            for (int i = Size - 1; i >= 0; i--)
            {
                parent = _contained[i];
                if (node.IsSubsetOf(parent))
                    break;
            }

            Parent[node] = parent;

            // The node will always be a leftchild if the previously inserted node had an even number, and vice versa
            // This assumes that we always add children of a node directly after each other
            if (Size % 2 == 0)
                RightChild[parent] = node;
            else
                LeftChild[parent] = node;

            _contained.Add(node);
        }
开发者ID:Miloan,项目名称:BooleanWidth,代码行数:38,代码来源:Tree.cs


注:本文中的BitSet.IsSubsetOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。