本文整理汇总了C#中HashSet.IsProperSubsetOf方法的典型用法代码示例。如果您正苦于以下问题:C# HashSet.IsProperSubsetOf方法的具体用法?C# HashSet.IsProperSubsetOf怎么用?C# HashSet.IsProperSubsetOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashSet
的用法示例。
在下文中一共展示了HashSet.IsProperSubsetOf方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsGroupTagsUnique
static bool IsGroupTagsUnique(List<CityPack> cities, HashSet<string> tags)
{
foreach (CityPack pack in cities)
{
if (tags.IsSubsetOf(pack.cities) && !tags.IsProperSubsetOf(pack.cities))
{
return false;
}
}
return true;
}
示例2: TestSubSetSuperSet
public void TestSubSetSuperSet ()
{
var aSet = new HashSet<int> { 1, 2 };
var bSet = new HashSet<int> { 1 };
Assert.IsTrue (aSet.IsSubsetOf (aSet));
Assert.IsTrue (bSet.IsSubsetOf (aSet));
Assert.IsTrue (bSet.IsProperSubsetOf (aSet));
Assert.IsFalse (aSet.IsProperSubsetOf (aSet));
Assert.IsTrue (aSet.IsSupersetOf (aSet));
Assert.IsTrue (aSet.IsSupersetOf (bSet));
Assert.IsTrue (aSet.IsProperSupersetOf (bSet));
Assert.IsFalse (aSet.IsProperSupersetOf (aSet));
}
示例3: IsQualifiedSubset
public static bool IsQualifiedSubset(QualifiedSubset subsetToTest, AccessStructure miniamlAccess)
{
foreach (var qualifiedSet in miniamlAccess.Accesses)
{
if (!(qualifiedSet is QualifiedSubset)) continue;
HashSet<int> a = new HashSet<int>(subsetToTest.Parties.Select(x => x.GetPartyId()));
var qs = (QualifiedSubset)qualifiedSet;
HashSet<int> b = new HashSet<int>(qs.Parties.Select(x => x.GetPartyId()));
if (b.IsProperSubsetOf(a) || b.IsSubsetOf(a)) return true;
}
return false;
}
示例4: ShouldReturnProperSubsetOfNumberRange
public void ShouldReturnProperSubsetOfNumberRange()
{
int minNumber = 3;
int maxNumber = 15;
UniqueRandomNumberGenerator g = new UniqueRandomNumberGenerator(minNumber, maxNumber);
ReadOnlyCollection<int> numbers = g.RemainingNumbers;
HashSet<int> initialSet = new HashSet<int>(numbers);
const int GeneratedRandomNumberCount = 3;
// Sanity check on test data
Debug.Assert(
GeneratedRandomNumberCount < initialSet.Count,
String.Format("The generated random number count {0} must be less than the count of initial numbers {1} for this test.", GeneratedRandomNumberCount, initialSet.Count));
Debug.WriteLine("Random Numbers");
int number = 0;
HashSet<int> actual = new HashSet<int>();
for (int i = 1; i <= GeneratedRandomNumberCount; i++)
{
number = g.NewRandomNumber();
actual.Add(number);
}
Assert.IsTrue(
actual.IsProperSubsetOf(initialSet),
"Generated numbers should be a subset of the set corresponding to the initial range.");
}
示例5: _ValidateResultMaterials
bool _ValidateResultMaterials(){
HashSet<Material> allMatsOnObjs = new HashSet<Material>();
for (int i = 0; i < objsToMesh.Count; i++){
if (objsToMesh[i] != null){
Material[] ms = MB_Utility.GetGOMaterials(objsToMesh[i]);
for (int j = 0; j < ms.Length; j++){
if (ms[j] != null) allMatsOnObjs.Add(ms[j]);
}
}
}
HashSet<Material> allMatsInMapping = new HashSet<Material>();
for (int i = 0; i < resultMaterials.Length; i++){
MB_MultiMaterial mm = resultMaterials[i];
if (mm.combinedMaterial == null){
Debug.LogError("Combined Material is null please create and assign a result material.");
return false;
}
Shader targShader = mm.combinedMaterial.shader;
for (int j = 0; j < mm.sourceMaterials.Count; j++){
if (mm.sourceMaterials[j] == null){
Debug.LogError("There are null entries in the list of Source Materials");
return false;
}
if (targShader != mm.sourceMaterials[j].shader){
Debug.LogWarning("Source material " + mm.sourceMaterials[j] + " does not use shader " + targShader + " it may not have the required textures. If not empty textures will be generated.");
}
if (allMatsInMapping.Contains(mm.sourceMaterials[j])){
Debug.LogError("A Material " + mm.sourceMaterials[j] + " appears more than once in the list of source materials in the source material to combined mapping. Each source material must be unique.");
return false;
}
allMatsInMapping.Add(mm.sourceMaterials[j]);
}
}
if (allMatsOnObjs.IsProperSubsetOf(allMatsInMapping)){
allMatsInMapping.ExceptWith(allMatsOnObjs);
Debug.LogWarning("There are materials in the mapping that are not used on your source objects: " + PrintSet(allMatsInMapping));
}
if (allMatsInMapping.IsProperSubsetOf(allMatsOnObjs)){
allMatsOnObjs.ExceptWith(allMatsInMapping);
Debug.LogError("There are materials on the objects to combine that are not in the mapping: " + PrintSet(allMatsOnObjs));
return false;
}
return true;
}
示例6: ShouldReturnProperSubsetOfNumberArray
public void ShouldReturnProperSubsetOfNumberArray()
{
int[] numbers = new int[] { 1, 2, 3, 4, 3, 6, 4, 8, 17, 42, 6 };
ConcurrentBag<int> initialBag = new ConcurrentBag<int>(numbers);
UniqueRandomNumberGenerator g = new UniqueRandomNumberGenerator(numbers);
const int GeneratedRandomNumberCount = 3;
// Sanity check on test data
Debug.Assert(
GeneratedRandomNumberCount < initialBag.Count,
String.Format("The generated random number count {0} must be less than the count of initial numbers {1} for this test.", GeneratedRandomNumberCount, initialBag.Count));
Debug.WriteLine("Random Numbers");
int number = 0;
ConcurrentBag<int> actualBag = new ConcurrentBag<int>();
for (int i = 1; i <= GeneratedRandomNumberCount; i++)
{
number = g.NewRandomNumber();
actualBag.Add(number);
}
HashSet<int> initialSet = new HashSet<int>(initialBag.AsEnumerable());
HashSet<int> actualSet = new HashSet<int>(actualBag.AsEnumerable());
Assert.IsTrue(
actualSet.IsProperSubsetOf(initialSet),
"Generated numbers should be a subset of the initial numbers.");
}
示例7: IsProperSubsetOfTest
public void IsProperSubsetOfTest()
{
var set = new HashSet<int>();
var arr = Enumerable.Range(0, 10).ToArray();
set.UnionWith(arr);
set.Remove(0);
Assert.IsTrue(set.IsProperSubsetOf(arr));
}
示例8: IsProperSubsetEmptySetOfTest
public void IsProperSubsetEmptySetOfTest()
{
var set = new HashSet<int>();
var arr = Enumerable.Range(0, 10).ToArray();
Assert.IsTrue(set.IsProperSubsetOf(arr));
}
示例9: GetOverloadGroupEquivalence
static OverloadGroupEquivalenceInfo GetOverloadGroupEquivalence(Dictionary<string, List<RuntimeArgument>> groupDefinitions)
{
OverloadGroupEquivalenceInfo overloadGroupsInfo = new OverloadGroupEquivalenceInfo();
if (!groupDefinitions.IsNullOrEmpty())
{
string[] groupNames = new string[groupDefinitions.Count];
groupDefinitions.Keys.CopyTo(groupNames, 0);
for (int i = 0; i < groupNames.Length; i++)
{
string group1 = groupNames[i];
HashSet<RuntimeArgument> group1Args = new HashSet<RuntimeArgument>(groupDefinitions[group1]);
for (int j = i + 1; j < groupNames.Length; j++)
{
string group2 = groupNames[j];
HashSet<RuntimeArgument> group2Args = new HashSet<RuntimeArgument>(groupDefinitions[group2]);
if (group1Args.IsProperSupersetOf(group2Args))
{
overloadGroupsInfo.SetAsSuperset(group1, group2);
}
else if (group1Args.IsProperSubsetOf(group2Args))
{
overloadGroupsInfo.SetAsSuperset(group2, group1);
}
else if (group1Args.SetEquals(group2Args))
{
overloadGroupsInfo.SetAsEquivalent(group1, group2);
}
else if (group1Args.Overlaps(group2Args))
{
overloadGroupsInfo.SetAsOverlapping(group1, group2);
}
else // the groups are disjoint.
{
overloadGroupsInfo.SetAsDisjoint(group1, group2);
}
}
}
}
return overloadGroupsInfo;
}
示例10: GetOverloadGroupEquivalence
private static OverloadGroupEquivalenceInfo GetOverloadGroupEquivalence(Dictionary<string, List<RuntimeArgument>> groupDefinitions)
{
OverloadGroupEquivalenceInfo info = new OverloadGroupEquivalenceInfo();
if (!groupDefinitions.IsNullOrEmpty())
{
string[] array = new string[groupDefinitions.Count];
groupDefinitions.Keys.CopyTo(array, 0);
for (int i = 0; i < array.Length; i++)
{
string str = array[i];
HashSet<RuntimeArgument> set = new HashSet<RuntimeArgument>(groupDefinitions[str]);
for (int j = i + 1; j < array.Length; j++)
{
string str2 = array[j];
HashSet<RuntimeArgument> other = new HashSet<RuntimeArgument>(groupDefinitions[str2]);
if (set.IsProperSupersetOf(other))
{
info.SetAsSuperset(str, str2);
}
else if (set.IsProperSubsetOf(other))
{
info.SetAsSuperset(str2, str);
}
else if (set.SetEquals(other))
{
info.SetAsEquivalent(str, str2);
}
else if (set.Overlaps(other))
{
info.SetAsOverlapping(str, str2);
}
else
{
info.SetAsDisjoint(str, str2);
}
}
}
}
return info;
}
示例11: SubsetsAndSupersets
public void SubsetsAndSupersets()
{
var set0 = new HashSet<int>();
var set1 = new HashSet<int>(new[] { 0, 1, 2, 3 });
var set2 = new HashSet<int>(new[] { 0, 1, 2, 3 });
var set3 = new HashSet<int>(new[] { 0, 1, 2, 3, 4 });
var set4 = new HashSet<int>(new[] { 0, 1, 2, 3, 5 });
Assert.That(() => { set1.IsProperSubsetOf(null); }, Throws.TypeOf(typeof(ArgumentNullException)));
Assert.That(() => { set1.IsProperSupersetOf(null); }, Throws.TypeOf(typeof(ArgumentNullException)));
Assert.That(() => { set1.IsSubsetOf(null); }, Throws.TypeOf(typeof(ArgumentNullException)));
Assert.That(() => { set1.IsSupersetOf(null); }, Throws.TypeOf(typeof(ArgumentNullException)));
Assert.IsTrue(set1.IsSubsetOf(set1));
Assert.IsTrue(set1.IsSubsetOf(set2));
Assert.IsTrue(set1.IsSubsetOf(set3));
Assert.IsFalse(set3.IsSubsetOf(set4));
Assert.IsFalse(set1.IsProperSubsetOf(set1));
Assert.IsFalse(set1.IsProperSubsetOf(set2));
Assert.IsTrue(set1.IsProperSubsetOf(set3));
Assert.IsFalse(set3.IsProperSubsetOf(set4));
Assert.IsFalse(set3.IsSubsetOf(set2));
Assert.IsFalse(set3.IsProperSubsetOf(set2));
Assert.IsTrue(set3.IsSupersetOf(set3));
Assert.IsTrue(set3.IsSupersetOf(set2));
Assert.IsFalse(set3.IsSupersetOf(set4));
Assert.IsFalse(set3.IsProperSupersetOf(set3));
Assert.IsTrue(set3.IsProperSupersetOf(set2));
Assert.IsFalse(set3.IsProperSupersetOf(set4));
// Empty set.
Assert.IsTrue(set0.IsSubsetOf(set0));
Assert.IsTrue(set0.IsSubsetOf(set1));
Assert.IsFalse(set0.IsProperSubsetOf(set0));
Assert.IsTrue(set0.IsProperSubsetOf(set1));
Assert.IsTrue(set0.IsSupersetOf(set0));
Assert.IsFalse(set0.IsProperSupersetOf(set0));
Assert.IsFalse(set0.IsSupersetOf(set1));
Assert.IsTrue(set0.IsProperSubsetOf(set1));
Assert.IsFalse(set1.IsSubsetOf(set0));
Assert.IsFalse(set1.IsProperSubsetOf(set0));
Assert.IsTrue(set1.IsSupersetOf(set0));
Assert.IsTrue(set1.IsProperSupersetOf(set0));
}