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


C# List.RemoveAll方法代码示例

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


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

示例1: RebuildStatisticsTable

		private void RebuildStatisticsTable()
		{
			statisticsBox.Clear();
			// TODO-Linux: SelectionTabs isn't implemented on Mono
			statisticsBox.SelectionTabs = new int[] { 10, 300};
			//retrieve the default UI font.
			var font = FontHeightAdjuster.GetFontForStyle(StyleServices.NormalStyleName,
														  FontHeightAdjuster.StyleSheetFromMediator(mediator),
														  Cache.DefaultUserWs, Cache.WritingSystemFactory);
			//increase the size of the default UI font and make it bold for the header.
			Font headerFont = new Font(font.FontFamily, font.SizeInPoints + 1.0f, FontStyle.Bold, font.Unit, font.GdiCharSet);

			//refresh the statisticsDescription (in case of font changes)
			statisticsBox.Text = ITextStrings.ksStatisticsView_HeaderText;

			int row = 0;
			var textList = InterestingTextsDecorator.GetInterestingTextList(mediator, Cache.ServiceLocator);
			int numberOfSegments = 0;
			int wordCount = 0;
			int uniqueWords = 0;

			Dictionary<int, int> languageCount = new Dictionary<int, int>();
			Dictionary<int, Set<String>> languageTypeCount = new Dictionary<int, Set<String>>();
			//for each interesting text
			foreach (var text in textList.InterestingTexts)
			{
				//if a text is deleted in Interlinear there could be a text in this list which has invalid data.
				if (text.Hvo < 0)
					continue;
				//for every paragraph in the interesting text
				for (int index = 0; index < text.ParagraphsOS.Count; ++index)
				{
					//count the segments in this paragraph
					numberOfSegments += text[index].SegmentsOS.Count;
					//count all the things analyzed as words
					var words = new List<IAnalysis>(text[index].Analyses);
					foreach (var word in words)
					{
						var wordForm = word.Wordform;
						if (wordForm != null)
						{
							var valdWSs = wordForm.Form.AvailableWritingSystemIds;
							foreach (var ws in valdWSs)
							{
								// increase the count of words(tokens) for this language
								int count = 0;
								if (languageCount.TryGetValue(ws, out count))
								{
									languageCount[ws] = count + 1;
								}
								else
								{
									languageCount.Add(ws, 1);
								}
								//increase the count of unique words(types) for this language
								Set<String> pair;
								if (languageTypeCount.TryGetValue(ws, out pair))
								{
									//add the string for this writing system in all lower case to the set, unique count is case insensitive
									pair.Add(word.Wordform.Form.get_String(ws).Text.ToLower());
								}
								else
								{
									//add the string for this writing system in all lower case to the set, unique count is case insensitive
									languageTypeCount.Add(ws, new Set<String> { word.Wordform.Form.get_String(ws).Text.ToLower() });
								}
							}
						}
					}
					words.RemoveAll(item => !item.HasWordform);
					wordCount += words.Count;
				}
			}
			// insert total word type count
			statisticsBox.Text += Environment.NewLine + Environment.NewLine + Environment.NewLine + "\t" + ITextStrings.ksStatisticsViewTotalWordTypesText + "\t"; // Todo: find the right System.?.NewLine constant

			++row;
			//add one row for the unique words in each language.
			foreach (KeyValuePair<int, Set<String>> keyValuePair in languageTypeCount)
			{
				var ws = Cache.WritingSystemFactory.get_EngineOrNull(keyValuePair.Key);

				string labText = (ws != null ? ws.ToString() : "#unknown#") + @":";
				statisticsBox.Text += Environment.NewLine + Environment.NewLine + "\t" + labText + "\t"; // Todo: find the right System.?.NewLine constant
				statisticsBox.Text += "" + keyValuePair.Value.Count;
				++row;
				uniqueWords += keyValuePair.Value.Count; //increase the total of unique words
			}

			// next insert the word count.
			statisticsBox.Text += Environment.NewLine + Environment.NewLine + Environment.NewLine + "\t" + ITextStrings.ksStatisticsViewTotalWordTokensText + "\t"; // Todo: find the right System.?.NewLine constant
			statisticsBox.Text += wordCount;
			++row;
			//add one row for the token count for each language.
			foreach (KeyValuePair<int, int> keyValuePair in languageCount)
			{
				var ws = Cache.WritingSystemFactory.get_EngineOrNull(keyValuePair.Key);

				string labText = (ws != null ? ws.ToString() : "#unknown#") + @":";
				statisticsBox.Text += Environment.NewLine + Environment.NewLine + "\t" + labText + "\t"; // Todo: find the right System.?.NewLine constant
//.........这里部分代码省略.........
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:101,代码来源:StatisticsView.cs


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