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


C# HashSet.IsProperSubsetOf方法代码示例

本文整理汇总了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;
 }
开发者ID:mikhaelmurmur,项目名称:HackerRank.com.Tasks,代码行数:11,代码来源:Program.cs

示例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));
		}
开发者ID:caloggins,项目名称:DOT-NET-on-Linux,代码行数:17,代码来源:HashSetExampleTests.cs

示例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;
        }
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:13,代码来源:AccessStructure.cs

示例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.");
        }
开发者ID:kevinmcfarlane,项目名称:ArcadiaTechnology.Tools,代码行数:31,代码来源:UniqueRandomNumberGeneratorTests.cs

示例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;
	}
开发者ID:watapax,项目名称:Antartica_AR,代码行数:45,代码来源:MB3_TextureBaker.cs

示例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.");
        }
开发者ID:kevinmcfarlane,项目名称:ArcadiaTechnology.Tools,代码行数:30,代码来源:UniqueRandomNumberGeneratorTests.cs

示例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));
 }
开发者ID:Confirmit,项目名称:Students,代码行数:8,代码来源:HashSetUnitTest.cs

示例8: IsProperSubsetEmptySetOfTest

 public void IsProperSubsetEmptySetOfTest()
 {
     var set = new HashSet<int>();
     var arr = Enumerable.Range(0, 10).ToArray();
     Assert.IsTrue(set.IsProperSubsetOf(arr));
 }
开发者ID:Confirmit,项目名称:Students,代码行数:6,代码来源:HashSetUnitTest.cs

示例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;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:44,代码来源:ValidationHelper.cs

示例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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:40,代码来源:ValidationHelper.cs

示例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));
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:44,代码来源:HashSetTest.cs


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