本文整理汇总了C#中SortedDictionary.Count方法的典型用法代码示例。如果您正苦于以下问题:C# SortedDictionary.Count方法的具体用法?C# SortedDictionary.Count怎么用?C# SortedDictionary.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedDictionary
的用法示例。
在下文中一共展示了SortedDictionary.Count方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllElementsFlattened
public void AllElementsFlattened()
{
using (var tempFile = new TempFile())
{
var sortedData = new SortedDictionary<string, XElement>();
CmObjectFlatteningService.FlattenOwnerlessObject(
tempFile.Path,
sortedData,
_reversalIndexElement);
Assert.AreEqual(7, sortedData.Count());
Assert.AreEqual(1, sortedData.Values.Count(rt => rt.Attribute(SharedConstants.Class).Value == "ReversalIndex"));
Assert.AreEqual(3, sortedData.Values.Count(rt => rt.Attribute(SharedConstants.Class).Value == "ReversalIndexEntry"));
Assert.AreEqual(1, sortedData.Values.Count(rt => rt.Attribute(SharedConstants.Class).Value == SharedConstants.CmPossibilityList));
Assert.AreEqual(2, sortedData.Values.Count(rt => rt.Attribute(SharedConstants.Class).Value == "PartOfSpeech"));
}
}
示例2: GetAtoZPages
private static SortedDictionary<string, AtoZInfo> GetAtoZPages(UmbracoHelper umbHelper, string[] excludedTypes, IPublishedContent root)
{
var cacheName = string.Format("AtoZPages_{0}", root.Id);
var appCache = ApplicationContext.Current.ApplicationCache;
SortedDictionary<string, AtoZInfo> azPages = appCache.GetCacheItem<SortedDictionary<string, AtoZInfo>>(cacheName);
if (azPages == null)
{
Stopwatch sw = new Stopwatch();
sw.Start();
// no cache - so we have to build it...
LogHelper.Debug<AtoZEventHelper>("Building AtoZ Cache");
azPages = new SortedDictionary<string, AtoZInfo>();
var sitePages = root.Descendants().Where(
x => x.IsVisible()
&& !excludedTypes.Contains(x.DocumentTypeAlias)
&& !x.GetPropertyValue<bool>("excludeFromAtoZSearch")
&& !x.HasProperty("isComponent"));
foreach(var page in sitePages)
{
var title = page.GetPropertyValue<string>("title", page.Name).Trim();
if (!azPages.ContainsKey(title))
{
azPages.Add(title, new AtoZInfo()
{
Url = page.Url,
Id = page.Id,
Title = title
});
}
}
appCache.InsertCacheItem <SortedDictionary<string, AtoZInfo>>
(cacheName, CacheItemPriority.Default, () => azPages);
sw.Stop();
LogHelper.Info<AtoZEventHelper>("Built atoz cache for {0} pages in {1}ms",
() => azPages.Count(), () => sw.ElapsedMilliseconds);
}
return azPages;
}
示例3: CheckDictionary
private bool CheckDictionary(SortedDictionary<Double, Double> d1, SortedDictionary<Double, Double> d2)
{
if (d1.Count() != d2.Count())
return false;
foreach (Double k in d1.Keys)
{
if (!d2.ContainsKey(k))
return false;
if (Math.Round(d1[k], 4) != d2[k])
return false;
}
return true;
}
示例4: SortedDictionaryToXml
/// <summary>
/// 将SortedDictionary转成xml
/// </summary>
/// <param name="orderParams">发送或者接收到的数据集合M按照ASCII码字典序集合</param>
/// <returns>xml(string)</returns>
public static string SortedDictionaryToXml(SortedDictionary<string, object> orderParams)
{
if (orderParams.Count() == 0)
return "";
string xml = "<xml>";
foreach (KeyValuePair<string, object> pair in orderParams)
{
if (pair.Value.GetType() == typeof(int))
{
xml += "<" + pair.Key + ">" + pair.Value + "</" + pair.Key + ">";
}
else if (pair.Value.GetType() == typeof(string))
{
xml += "<" + pair.Key + ">" + "<![CDATA[" + pair.Value + "]]></" + pair.Key + ">";
}
}
xml += "</xml>";
return xml;
}
示例5: SaveCreatesTaskAndAppendsVersion
public void SaveCreatesTaskAndAppendsVersion()
{
// Arrange.
const string name = "task name";
var date = new DateTime(2000, 1, 1);
var version = new TaskVersion(date);
var task = new Task(name);
var versions = new SortedDictionary<DateTime, TaskVersion>();
var store = MockRepository.GeneratePartialMock<MemoryTaskStore>();
store.Expect(s => s.GetVersions(name)).Return(versions);
store.Expect(s => s.New(name, versions)).Return(task);
// Act.
var res = store.Save(name, version);
// Assert.
store.VerifyAllExpectations();
Assert.AreEqual(task, res);
Assert.AreEqual(1, versions.Count());
Assert.AreEqual(version, versions[date]);
}
示例6: foreach
/*private SortedDictionary<double, double> FillLocalResultCycles()
{
SortedDictionary<double, double> r = new SortedDictionary<double, double>();
for (int i = 0; i < assemblyToAnalyze.Count(); ++i)
{
int size = assemblyToAnalyze[i].Size;
int instanceCount = assemblyToAnalyze[i].Results.Count();
for (int j = 0; j < instanceCount; ++j)
{
SortedDictionary<int, long> tempDictionary = assemblyToAnalyze[i].Results[j].Cycles;
SortedDictionary<int, long>.KeyCollection keyColl = tempDictionary.Keys;
foreach (int key in keyColl)
{
if (r.Keys.Contains(key))
r[key] += (double)tempDictionary[key] / size;
else
r.Add(key, (double)tempDictionary[key] / size);
}
}
}
return r;
}*/
private SortedDictionary<double, double> GetLocalResult(AnalyseOptions option,
SortedDictionary<double, double> t)
{
SortedDictionary<double, double> r = new SortedDictionary<double, double>();
SortedDictionary<double, double>.KeyCollection keys = t.Keys;
foreach (double key in keys)
{
r.Add(key, t[key] / GetRealizationsCount());
}
FillMathWaitingsAndDispersions(r, option);
int thickening = 0;
if (analyzeOptions[option].useDelta)
thickening = (int)analyzeOptions[option].optionValue;
else
thickening = (int)Math.Ceiling(((analyzeOptions[option].optionValue * r.Count()) / 100));
return UseThickening(r, thickening);
}
示例7: get_top
public SortedDictionary<String, double> get_top(int n)
{
SortedDictionary<String, double> best_so_fars = new SortedDictionary<String, double>();
double worst_score_in_best = -100.0; // assume dt small enough so nobody negative
foreach(var pair in phrases)
{
double score = pair.Value.get_importance();
String sentence = pair.Key;
if(sentence.Split().Count() <= 1) {continue;} // don't include single words.
if(best_so_fars.Count() < n)
{
if(!best_so_fars.ContainsKey(sentence)) {best_so_fars.Add(sentence, score);}
if(score < worst_score_in_best) {worst_score_in_best = score;}
}
else if(score > worst_score_in_best)
{
if(!best_so_fars.ContainsKey(sentence)) {best_so_fars.Add(sentence, score);}
best_so_fars.Remove(best_so_fars.First().Key);
}
} return best_so_fars;
}