本文整理汇总了C#中System.Collections.SortedSet.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# SortedSet.Clear方法的具体用法?C# SortedSet.Clear怎么用?C# SortedSet.Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.SortedSet
的用法示例。
在下文中一共展示了SortedSet.Clear方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DataSet
/***************************** Constructor *********************************/
public DataSet()
{
egoLikedTweets = new HashSet<long>();
egoLikedTweetsInTimeline = new HashSet<long>();
egoUnLikedTweetsInTimeline = new HashSet<long>();
timeline = new SortedSet<long>(new TweetIDComparer());
egoLikedTweets.Clear();
egoLikedTweetsInTimeline.Clear();
egoUnLikedTweetsInTimeline.Clear();
timeline.Clear();
}
示例2: RunTest
private static void RunTest(SortedDictionary<int, User> sortedDict, SortedSet<User> sortedSet, IEnumerable<int> testSizes,
string label,
Func<SortedDictionary<int, User>, int, TimeSpan> testFuncSoretdDict, Func<SortedSet<User>, int, TimeSpan> testFuncSortedSet)
{
foreach (int test in testSizes)
{
var result = testFuncSoretdDict(sortedDict, test);
Console.WriteLine("{0} with Sorted Dictionary ({1}): {2}", label, test, result);
result = testFuncSortedSet(sortedSet, test);
Console.WriteLine("{0} with Sorted Set ({1}): {2}", label, test, result);
sortedDict.Clear();
sortedSet.Clear();
Console.WriteLine();
}
}
示例3: Clear
public void Clear ()
{
var set = new SortedSet<int> { 2, 3, 4, 5 };
Assert.AreEqual (4, set.Count);
set.Clear ();
Assert.AreEqual (0, set.Count);
}
示例4: CheckOutcomeCore
public override Outcome CheckOutcomeCore(ErrorHandler handler, int taskID = -1)
{
Contract.EnsuresOnThrow<UnexpectedProverOutputException>(true);
var result = Outcome.Undetermined;
if (Process == null)
return result;
try {
currentErrorHandler = handler;
FlushProverWarnings();
int errorLimit;
if (CommandLineOptions.Clo.ConcurrentHoudini) {
Contract.Assert(taskID >= 0);
errorLimit = CommandLineOptions.Clo.Cho[taskID].ProverCCLimit;
} else {
errorLimit = CommandLineOptions.Clo.ProverCCLimit;
}
if (errorLimit < 1)
errorLimit = 1;
int errorsLeft = errorLimit;
var globalResult = Outcome.Undetermined;
while (true) {
string[] labels = null;
bool popLater = false;
try {
errorsLeft--;
result = GetResponse();
var reporter = handler as VC.VCGen.ErrorReporter;
// TODO(wuestholz): Is the reporter ever null?
if (usingUnsatCore && result == Outcome.Valid && reporter != null && 0 < NamedAssumes.Count)
{
if (usingUnsatCore)
{
UsedNamedAssumes = new HashSet<string>();
SendThisVC("(get-unsat-core)");
var resp = Process.GetProverResponse();
if (resp.Name != "")
{
UsedNamedAssumes.Add(resp.Name);
if (CommandLineOptions.Clo.PrintNecessaryAssumes)
{
reporter.AddNecessaryAssume(resp.Name.Substring("aux$$assume$$".Length));
}
}
foreach (var arg in resp.Arguments)
{
UsedNamedAssumes.Add(arg.Name);
if (CommandLineOptions.Clo.PrintNecessaryAssumes)
{
reporter.AddNecessaryAssume(arg.Name.Substring("aux$$assume$$".Length));
}
}
}
else
{
UsedNamedAssumes = null;
}
}
if (CommandLineOptions.Clo.RunDiagnosticsOnTimeout && result == Outcome.TimeOut)
{
#region Run timeout diagnostics
if (CommandLineOptions.Clo.TraceDiagnosticsOnTimeout)
{
Console.Out.WriteLine("Starting timeout diagnostics with initial time limit {0}.", options.TimeLimit);
}
SendThisVC("; begin timeout diagnostics");
var start = DateTime.UtcNow;
var unverified = new SortedSet<int>(ctx.TimeoutDiagnosticIDToAssertion.Keys);
var timedOut = new SortedSet<int>();
int frac = 2;
int queries = 0;
int timeLimitPerAssertion = 0 < options.TimeLimit ? (options.TimeLimit / 100) * CommandLineOptions.Clo.TimeLimitPerAssertionInPercent : 1000;
while (true)
{
int rem = unverified.Count;
if (rem == 0)
{
if (0 < timedOut.Count)
{
result = CheckSplit(timedOut, ref popLater, options.TimeLimit, timeLimitPerAssertion, ref queries);
if (result == Outcome.Valid)
{
timedOut.Clear();
}
else if (result == Outcome.TimeOut)
{
//.........这里部分代码省略.........
示例5: ProcessChildren
/// <summary>
/// Handle 'special' Panels
/// </summary>
public override void ProcessChildren(TFormWriter writer, TControlDef ctrl)
{
SortedSet <int>ButtonWidths = new SortedSet <int>();
SortedSet <int>ButtonTops = new SortedSet <int>();
List <TControlDef>Buttons = new List <TControlDef>();
int NewButtonWidthForAll = -1;
if (ctrl.controlName == PNL_FILTER_AND_FIND)
{
listNumericColumns.Clear();
writer.Template.SetCodelet("FILTERANDFIND", "true");
writer.SetControlProperty(ctrl, "Dock", "Left");
writer.SetControlProperty(ctrl, "BackColor", "System.Drawing.Color.LightSteelBlue");
writer.SetControlProperty(ctrl, "Width", "0");
if (!ctrl.HasAttribute("ExpandedWidth"))
{
writer.Template.SetCodelet("FINDANDFILTERINITIALWIDTH", "150");
}
else
{
writer.Template.SetCodelet("FINDANDFILTERINITIALWIDTH", ctrl.GetAttribute("ExpandedWidth"));
}
if ((ctrl.HasAttribute("InitiallyExpanded"))
&& (ctrl.GetAttribute("InitiallyExpanded").ToLower() != "false"))
{
writer.Template.SetCodelet("FINDANDFILTERINITIALLYEXPANDED", "true");
}
else
{
writer.Template.SetCodelet("FINDANDFILTERINITIALLYEXPANDED", "false");
}
if (!ctrl.HasAttribute("ShowApplyFilterButton"))
{
writer.Template.SetCodelet("FINDANDFILTERAPPLYFILTERBUTTONCONTEXT", "TUcoFilterAndFind.FilterContext.None");
}
else
{
writer.Template.SetCodelet("FINDANDFILTERAPPLYFILTERBUTTONCONTEXT", "TUcoFilterAndFind." +
ctrl.GetAttribute("ShowApplyFilterButton"));
}
if (!ctrl.HasAttribute("ShowKeepFilterTurnedOnButton"))
{
writer.Template.SetCodelet("FINDANDFILTERSHOWKEEPFILTERTURNEDONBUTTONCONTEXT", "TUcoFilterAndFind.FilterContext.None");
}
else
{
writer.Template.SetCodelet("FINDANDFILTERSHOWKEEPFILTERTURNEDONBUTTONCONTEXT", "TUcoFilterAndFind." +
ctrl.GetAttribute("ShowKeepFilterTurnedOnButton"));
}
if (!ctrl.HasAttribute("ShowFilterIsAlwaysOnLabel"))
{
writer.Template.SetCodelet("FINDANDFILTERSHOWFILTERISALWAYSONLABELCONTEXT", "TUcoFilterAndFind.FilterContext.None");
}
else
{
writer.Template.SetCodelet("FINDANDFILTERSHOWFILTERISALWAYSONLABELCONTEXT", "TUcoFilterAndFind." +
ctrl.GetAttribute("ShowFilterIsAlwaysOnLabel"));
}
writer.Template.SetCodelet("CUSTOMDISPOSING",
"if (FFilterAndFindObject != null && FFilterAndFindObject.FilterFindPanel != null)" + Environment.NewLine +
"{" + Environment.NewLine +
" FFilterAndFindObject.FilterFindPanel.Dispose();" + Environment.NewLine +
"}");
XmlNodeList controlAttributesList = null;
XmlNode ctrlNode = ctrl.xmlNode;
foreach (XmlNode child in ctrlNode.ChildNodes)
{
if (child.Name == "ControlAttributes")
{
controlAttributesList = child.ChildNodes;
}
}
ProcessTemplate snippetFilterAndFindDeclarations = writer.Template.GetSnippet("FILTERANDFINDDECLARATIONS");
writer.Template.InsertSnippet("FILTERANDFINDDECLARATIONS", snippetFilterAndFindDeclarations);
ProcessTemplate snippetFilterAndFindMethods = writer.Template.GetSnippet("FILTERANDFINDMETHODS");
writer.Template.SetCodelet("INDIVIDUALFILTERPANELS", "");
writer.Template.SetCodelet("INDIVIDUALEXTRAFILTERPANELS", "");
writer.Template.SetCodelet("INDIVIDUALFINDPANELS", "");
writer.Template.SetCodelet("INDIVIDUALFILTERFINDPANELEVENTS", "");
writer.Template.SetCodelet("INDIVIDUALFILTERFINDPANELPROPERTIES", "");
writer.Template.SetCodelet("NUMERICFILTERFINDCOLUMNS", "");
writer.Template.SetCodelet("FILTERBUTTON", "");
//.........这里部分代码省略.........
示例6: RunTestTwoSortedSet
/// <summary>
/// test adds several items to the collection, and then enumerates the collection in sorted order. The test is repeated 50 times to get a more consistent result
/// </summary>
/// <param name="collection"></param>
/// <param name="numItemsToTest"></param>
/// <returns></returns>
static TimeSpan RunTestTwoSortedSet(SortedSet<User> collection, int numItemsToTest)
{
Stopwatch timer = new Stopwatch();
timer.Start();
// perform the test 50 times:
for (int counter = 0; counter < 50; counter++)
{
collection.Clear();
// add random items
Random rnd = new Random();
var sequence = from n in Enumerable.Range(1, numItemsToTest)
select rnd.Next() * n;
foreach (var item in sequence)
collection.Add(new User(item, "family", "name"));
// enumerate 1000 times
double sum = 0;
for (int inner = 0; inner < 1000; inner++)
{
// I am performing the sort each time through the loop on purpose, even though it does take more time.
// I want to measure the cost of the sort because in most applications where order matters, you would need
// to enumerate the set in different locations in the code, or after items have been added or removed.
// That requires a sort.
// IEnumerable ordered = collection as IEnumerable;
//SortedDictionary<int, User>.ValueCollection values = collection.Values;
//var max = collection.Values.Max();
IEnumerable ordered = collection as IEnumerable;
// var sum = collection.Values.Sum();
// must enumerate to make it work:
// sum += ordered.Sum();
ordered.GetEnumerator();
}
}
timer.Stop();
return timer.Elapsed;
}
示例7: RunTestOneSortedSet
/// <summary>
/// adds several items to a collection, then searches for items in that collection. The test is repeated 50 times to get a more consistent result
/// </summary>
/// <param name="collection"></param>
/// <param name="numItemsToTest"></param>
/// <returns></returns>
static TimeSpan RunTestOneSortedSet(SortedSet<User> collection, int numItemsToTest)
{
Stopwatch timer = new Stopwatch();
timer.Start();
// perform the test 50 times:
for (int counter = 0; counter < 50; counter++)
{
collection.Clear();
// add some random items
Random rnd = new Random();
var sequence = from n in Enumerable.Range(1, numItemsToTest)
select rnd.Next() * n;
foreach (var item in sequence)
collection.Add(new User(item, "family", "name"));
// search for 1000 random items
var sequence2 = from n in Enumerable.Range(1, 1000)
select rnd.Next() * n;
bool found = false;
foreach (var item in sequence2)
{
// This method is an O(ln n) operation.
found &= collection.Contains(new User(item, "family", "name"));
}
}
timer.Stop();
return timer.Elapsed;
}