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


C# Set.Intersection方法代码示例

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


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

示例1: IntersectionTest

        public void IntersectionTest()
        {
            var a = new Set<int>(1, 2, 3);
            var b = new Set<int>(2, 3, 4);

            Console.WriteLine(a.Intersection(b));
        }
开发者ID:rodriada000,项目名称:Mathos-Project,代码行数:7,代码来源:SetTest.cs

示例2: IntersectionTest

 public void IntersectionTest()
 {
     var a = new Set<int>(1, 2, 3);
     var b = new Set<int>(2, 3, 4);
     
     Assert.AreEqual("{2,3}", a.Intersection(b).ToString());
 }
开发者ID:furesoft,项目名称:Mathos-Project,代码行数:7,代码来源:SetTest.cs

示例3: Intersection

        public void Intersection()
        {
            var s1 = new Set<string>() { "Apple", "Banana", "three" };
            var s2 = new Set<string>() { "one", "Banana", "Apple" };

            var s3 = s1.Intersection(s2);
            Console.Out.WriteLine(s3);

            Assert.That(s3, Has.Count.EqualTo(2), "Incorrect number of elements.");
            Assert.That(s3, Has.Member("Banana"), "Missing element");
        }
开发者ID:tbashore,项目名称:TLib.NET,代码行数:11,代码来源:SetTests.cs

示例4: IntersectionTest

 public void IntersectionTest()
 {
     var firstSet = new Set<string>();
     var secondSet = new Set<string>();
     firstSet.Add("lol");
     firstSet.Add("olo");
     firstSet.Add("lol");
     secondSet.Add("ololo");
     secondSet.Add("lol");
     var newSet = firstSet.Intersection(secondSet);
     Assert.IsTrue(newSet.Contains("lol"));
     Assert.IsFalse(newSet.Contains("ololo"));
     Assert.IsTrue(firstSet.Contains("olo"));
     Assert.IsTrue(secondSet.Contains("ololo"));
 }
开发者ID:Ivan-Nebogatikov,项目名称:Homeworks,代码行数:15,代码来源:SetTests.cs

示例5: IntersectionTest

 public void IntersectionTest()
 {
     var set = new Set<int>();
     set.Add(1);
     set.Add(2);
     set.Add(3);
     var set2 = new Set<int>();
     set2.Add(1);
     set2.Add(2);
     set2.Add(4);
     var result = set.Intersection(set2);
     Assert.IsTrue(result.Contains(1));
     Assert.IsTrue(result.Contains(2));
     Assert.IsFalse(result.Contains(3));
     Assert.IsFalse(result.Contains(4));
 }
开发者ID:Julia-Berezhnova,项目名称:Semester-2,代码行数:16,代码来源:SetTests.cs

示例6: AllWillChange

		/// <summary>
		/// Return true if every remaining item will change. True if all enabled items are also checked, and there
		/// are no known items that aren't listed at all (e.g., Scripture not currently included).
		/// </summary>
		/// <param name="someWillChange">Set true if some item will change, that is, some checked item is enabled</param>
		/// <returns></returns>
		private bool AllWillChange(out bool someWillChange)
		{
			var checkedItems = new Set<int>(m_sourceSentences.CheckedItems);
			var changeCount = checkedItems.Intersection(m_enabledItems).Count;
			someWillChange = changeCount > 0;
			return changeCount == m_enabledItems.Count && !m_fOtherOccurrencesExist;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:13,代码来源:RespellerDlg.cs

示例7: SetAffectedCcas

		/// <summary>
		/// Takes the list of AffectedCcas fed into the dialog and the list of user selected wfics
		/// and updates the AffectedCcas list in the parameter object
		/// </summary>
		internal void SetAffectedCcas(int[] selectedWfics)
		{
			Set<int> selWfics = new Set<int>();
			selWfics.AddRange(selectedWfics);
			List<int> ccas = new List<int>();
			foreach (int hvoCca in SentElem.AffectedCcas)
			{
				if (selWfics.Intersection(Cache.GetVectorProperty(hvoCca, kflidAppliesTo, false)).Count > 0)
					ccas.Add(hvoCca);
			}
			SentElem.AffectedCcas = ccas;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:16,代码来源:AdvancedMTDialog.cs

示例8: GetTaggingReferencingTheseWords

		/// <summary>
		/// Gets a list of TextTags that reference the analysis occurrences in the input paramter.
		/// Will need enhancement to work with multi-segment tags.
		/// </summary>
		/// <param name="occurrences"></param>
		/// <returns>A set of tags.</returns>
		internal static Set<ITextTag> GetTaggingReferencingTheseWords(List<AnalysisOccurrence> occurrences)
		{
			var results = new Set<ITextTag>();
			if (occurrences.Count == 0 || !occurrences[0].IsValid)
				return results;
			var text = occurrences[0].Segment.Paragraph.Owner as IStText;
			if (text == null)
				throw new NullReferenceException("Unexpected error!");
			var tags = text.TagsOC;
			if (tags.Count == 0)
				return results;

			// Quick cast to Set<>
			var occurenceSet = new Set<AnalysisOccurrence>();
			occurenceSet.AddRange(occurrences);

			// Collect all segments referenced by these words
			var segsUsed = new Set<ISegment>();
			segsUsed.AddRange(from occurrence in occurenceSet
								select occurrence.Segment);

			// Collect all tags referencing those segments
			var tagsRefSegs = new Set<ITextTag>();
			// Enhance: This won't work for multi-segment tags where a tag can reference 3+ segments.
			// but see note on foreach below.
			tagsRefSegs.AddRange(from ttag in tags
									 where segsUsed.Contains(ttag.BeginSegmentRA) || segsUsed.Contains(ttag.EndSegmentRA)
									 select ttag);

			foreach (var ttag in tagsRefSegs) // A slower, but more complete form can replace tagsRefSegs with tags here.
				if (occurenceSet.Intersection(ttag.GetOccurrences()).Count > 0)
					results.Add(ttag);

			return results;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:41,代码来源:InterlinTaggingChild.cs

示例9: CheckForOtherOccurrences

		void CheckForOtherOccurrences()
		{
			string qry = string.Format(
				"SELECT cbawf.Id " +
				"FROM CmBaseAnnotation_ cbawf " +
				"WHERE cbawf.InstanceOf = {0} AND cbawf.BeginObject is not null " +
				"UNION " +
				"SELECT cbaAnal.Id " +
				"FROM CmBaseAnnotation_ cbaAnal " +
				"JOIN WfiAnalysis_ anal ON anal.Owner$ = {0}" +
				"WHERE cbaAnal.InstanceOf = anal.Id AND cbaAnal.BeginObject is not null " +
				"UNION " +
				"SELECT cbaGloss.Id " +
				"FROM CmBaseAnnotation_ cbaGloss " +
				"JOIN WfiAnalysis_ anal ON anal.Owner$ = {0}" +
				"JOIN WfiGloss_ gloss ON gloss.Owner$ = anal.Id " +
				"WHERE cbaGloss.InstanceOf = gloss.Id AND cbaGloss.BeginObject is not null ", m_srcwfiWordform.Hvo.ToString());
			Set<int> realOccurrences = new Set<int>(DbOps.ReadIntArrayFromCommand(m_cache, qry, null));
			// There are 'other' occurrences if some of the real ones aren't in the displayed list.
			m_fOtherOccurrencesExist = realOccurrences.Intersection(m_enabledItems).Count != realOccurrences.Count;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:21,代码来源:RespellerDlg.cs

示例10: SetAffectedWordGroups

		/// <summary>
		/// Takes the list of AffectedWordGroups fed into the dialog and the list of user selected words
		/// and updates the AffectedWordGroups list in the parameter object
		/// </summary>
		internal void SetAffectedWordGroups(AnalysisOccurrence[] selectedWords)
		{
			var selWords = new Set<AnalysisOccurrence>();
			selWords.AddRange(selectedWords);
			var affectedWordGrps = (from wordGroup in SentElem.AffectedWordGroups
									let wordGrpPoints = wordGroup.GetOccurrences()
									where selWords.Intersection(wordGrpPoints).Count > 0
									select wordGroup).ToList();
			SentElem.AffectedWordGroups = affectedWordGrps;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:14,代码来源:AdvancedMTDialog.cs


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