本文整理汇总了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;
}
示例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);
}