本文整理汇总了C#中Set.IsSubsetOf方法的典型用法代码示例。如果您正苦于以下问题:C# Set.IsSubsetOf方法的具体用法?C# Set.IsSubsetOf怎么用?C# Set.IsSubsetOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set.IsSubsetOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SimpleValueTests
public void SimpleValueTests()
{
Set<int> empty = new Set<int>();
Set<int> a = new Set<int>(1, 2, 3);
Set<int> b = new Set<int>(3, 4, 5);
Set<int> a_and_b = a + b;
Assert.AreEqual("{}", empty.ToString());
Assert.AreEqual("{ 1, 2, 3 }", a.ToString());
Assert.AreEqual("{ 3, 4, 5 }", b.ToString());
Assert.AreEqual("{ 1, 2, 3, 4, 5 }", a_and_b.ToString());
Assert.AreEqual("{}", (empty * a).ToString());
Assert.AreEqual("{}", (a * empty).ToString());
Assert.IsTrue(a_and_b * a == a);
Assert.IsTrue((a_and_b * a).Equals(a));
Assert.IsTrue(a_and_b - a == new Set<int>(4, 5));
Assert.IsTrue(a - a == new Set<int>());
Assert.IsTrue(a * a == a);
Assert.IsTrue(a.IsSubsetOf(a_and_b));
Assert.IsTrue(b.IsSubsetOf(a_and_b));
Assert.IsTrue(a_and_b.IsSubsetOf(a_and_b));
Assert.IsTrue(a.IsSubsetOf(a));
Assert.IsTrue(b.IsSubsetOf(b));
Assert.IsFalse(a.IsSubsetOf(b));
Assert.IsFalse(b.IsSubsetOf(a));
Assert.IsFalse(a_and_b.IsSubsetOf(a));
Assert.IsFalse(a_and_b.IsSubsetOf(b));
Set<int> a_copy = a.Copy();
Set<int> b_copy = b.Copy();
a.UnionUpdate(b);
Assert.AreEqual(a, a_and_b);
a.DifferenceUpdate(b);
Assert.AreEqual(a, a_and_b - b);
a.UnionUpdate(9);
Assert.AreEqual(a, (a_and_b - b) + new Set<int>(9));
a.DifferenceUpdate(1);
Assert.AreEqual(a, (a_and_b - b) + new Set<int>(9) - new Set<int>(1));
a_copy.IntersectionUpdate(b_copy);
Assert.AreEqual(new Set<int>(3), a_copy);
}
示例2: IsSubsetOf_OtherSet_AllShouldPass
public void IsSubsetOf_OtherSet_AllShouldPass(int[] firstArray, int[] secondArray, bool expected)
{
var firstSet = new Set<int>(firstArray);
var secondSet = new Set<int>(secondArray);
bool actual = firstSet.IsSubsetOf(secondSet);
Assert.Equal(expected, actual);
}