本文整理汇总了C#中SortedSet.Reverse方法的典型用法代码示例。如果您正苦于以下问题:C# SortedSet.Reverse方法的具体用法?C# SortedSet.Reverse怎么用?C# SortedSet.Reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedSet
的用法示例。
在下文中一共展示了SortedSet.Reverse方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get
public List<Card> Get(SortedSet<int> indexs)
{
List<Card> cs = new List<Card>();
foreach (var i in indexs.Reverse())
{
cs.Add(cards_[i]);
cards_.RemoveAt(i);
}
return cs;
}
示例2: TestReverseEnumerator
public static void TestReverseEnumerator()
{
SortedSet<int> sortedSet = new SortedSet<int>();
sortedSet.Clear();
for (int j = 5000; j > 0; j--)
{
if (!sortedSet.Contains(j))
sortedSet.Add(j);
}
int[] output = new int[5000];
sortedSet.CopyTo(output, 0);
int index = 0;
IEnumerator<int> e = sortedSet.Reverse().GetEnumerator();
while (e.MoveNext())
{
int recd = e.Current;
Assert.Equal(recd, output[sortedSet.Count - 1 - index]); //"mismatched reversal"
index++;
}
}
示例3: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
resmgr = ((System.Resources.ResourceManager)ApplicationResourceTable.Get());
requestPage = Page as SharedBasePage;
#region Setup Year Hyperlinks
DateTime[] daysWithEntries = null;
//Print out a list of all the years that have entries
// with links to the Year View
if ( requestPage.SiteConfig.AdjustDisplayTimeZone )
{
daysWithEntries = requestPage.DataService.GetDaysWithEntries(requestPage.SiteConfig.GetConfiguredTimeZone());
}
else
{
daysWithEntries = requestPage.DataService.GetDaysWithEntries(new newtelligence.DasBlog.Util.UTCTimeZone());
}
var years = new SortedSet<int>();
foreach (DateTime date in daysWithEntries) years.Add(date.Year);
foreach(int year in years.Reverse<int>())
{
HyperLink h = new HyperLink();
h.NavigateUrl = GetUrlWithYear(year);
h.Text = year.ToString();
contentPlaceHolder.Controls.Add(h);
Literal l = new Literal();
l.Text = " ";
contentPlaceHolder.Controls.Add(l);
}
Literal l2 = new Literal();
l2.Text = "<br /><br />";
contentPlaceHolder.Controls.Add(l2);
#endregion
#region Year View
//I know this could be cleaner and the Year viewing code could better share the Month viewing code
// but they are sufficiently different that I chose to keep them fairly separate
if (Request.QueryString["year"] != null)
{
int year = int.Parse(Request.QueryString["year"]);
int monthsInYear = System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar.GetMonthsInYear(year);
for(int i = 1; i <= monthsInYear; i++)
{
MonthViewCalendar c = new MonthViewCalendar();
ApplyCalendarStyles(c);
c.DayRender += new DayRenderEventHandler(calendarMonth_DayRender);
c.VisibleMonthChanged += new MonthChangedEventHandler(calendarMonth_VisibleMonthChanged);
c.SelectionChanged += new EventHandler(calendarMonth_SelectionChanged);
c.PreRender += new EventHandler(calendarMonth_PreRender);
//Don't show the Next/Prev for the Year Calendar
c.ShowNextPrevMonth = false;
//Tell this Calendar to show a specific month
c.VisibleDate = new DateTime(year, i, 1);
contentPlaceHolder.Controls.Add(c);
}
requestPage.TitleOverride = year.ToString();
}
#endregion
else //Month View
#region Month View
{
//Setup the Event Handlers for the Calendar
calendarMonth.DayRender += new DayRenderEventHandler(calendarMonth_DayRender);
calendarMonth.VisibleMonthChanged += new MonthChangedEventHandler(calendarMonth_VisibleMonthChanged);
calendarMonth.SelectionChanged += new EventHandler(calendarMonth_SelectionChanged);
calendarMonth.PreRender += new EventHandler(calendarMonth_PreRender);
ApplyCalendarStyles(calendarMonth);
contentPlaceHolder.Controls.Add(calendarMonth);
//Default to this month, otherwise parse out a yyyy-MM
if ( Request.QueryString["month"] == null )
{
_month = DateTime.Now.Date;
}
else
{
try
{
_month = DateTime.ParseExact(Request.QueryString["month"],"yyyy-MM", System.Globalization.CultureInfo.InvariantCulture);
}
catch
{
}
}
//Set the title, and tell the calendar to show today
requestPage.TitleOverride = _month.ToString("MMMM, yyyy");
calendarMonth.VisibleDate = _month;
}
//.........这里部分代码省略.........
示例4: GetRuns
private static Queue<Run> GetRuns(string Path_To_File)
{
Queue<Run> ResultedRuns = new Queue<Run>();
Run CurrentRun = new Run();
using (StreamReader rdr = new StreamReader(@"Unsorted files\" + Path_To_File)){
SortedSet<int> SortedHeap = new SortedSet<int>();
SortedHeap.Reverse();
List<int> ReserveList = new List<int>();
for (int i = 0; i < 4; i++)
SortedHeap.Add(Int32.Parse(rdr.ReadLine()));
do{
while (SortedHeap.Count != 0){
int pretendent = SortedHeap.First();
SortedHeap.Remove(SortedHeap.First());
CurrentRun.Enqueue(pretendent);
if (!rdr.EndOfStream){
int Next = Int32.Parse(rdr.ReadLine());
if (Next >= pretendent)
SortedHeap.Add(Next);
else
ReserveList.Add(Next);
}
}
SortedHeap = new SortedSet<int>(ReserveList);
ReserveList = new List<int>();
ResultedRuns.Enqueue(CurrentRun);
CurrentRun = new Run();
} while (SortedHeap.Count != 0);
}
return ResultedRuns;
}
示例5: RemoveRedundantMethods
// Remove overridden methods, methods that differ by const/non-const return values
// and abstract class constructors
void RemoveRedundantMethods()
{
// Remove by index, not by reference, otherwise the wrong method could be removed.
// MethodDefinition.Equals compares methods from the POV of C#, not C++,
// so const/non-const methods will be equal.
var removedMethodsIndices = new SortedSet<int>();
foreach (var @class in Project.ClassDefinitions.Values)
{
for (int i = 0; i < @class.Methods.Count; i++)
{
var method = @class.Methods[i];
if (method.IsConstructor)
{
if (@class.IsAbstract) removedMethodsIndices.Add(i);
continue;
}
// Check if the method already exists in a base class
var baseClass = @class.BaseClass;
while (baseClass != null)
{
var baseMethod = baseClass.Methods.FirstOrDefault(m => m.Equals(method));
if (baseMethod != null)
{
if (baseMethod.IsExcluded)
{
method.IsExcluded = true;
}
else
{
removedMethodsIndices.Add(i);
}
break;
}
baseClass = baseClass.BaseClass;
}
for (int j = i + 1; j < @class.Methods.Count; j++)
{
var method2 = @class.Methods[j];
if (!method.Equals(method2)) continue;
var type1 = method.ReturnType;
var type2 = method2.ReturnType;
bool const1 = type1.IsConst || (type1.Referenced != null && type1.Referenced.IsConst);
bool const2 = type2.IsConst || (type2.Referenced != null && type2.Referenced.IsConst);
// Prefer non-const return value
if (const1)
{
if (!const2)
{
removedMethodsIndices.Add(i);
break;
}
}
else if (const2)
{
removedMethodsIndices.Add(j);
break;
}
// Couldn't see the difference
//throw new NotImplementedException();
}
}
foreach (int i in removedMethodsIndices.Reverse())
{
@class.Methods.RemoveAt(i);
}
removedMethodsIndices.Clear();
}
}
示例6: GetHighScore
private static void GetHighScore()
{
int counter = 0;
SortedSet<User> highScore = new SortedSet<User>();
string line;
using (StreamReader file = new StreamReader(@"../../HighScore.txt"))
{
while ((line = file.ReadLine()) != null)
{
string[] highScoreValues = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
string name = highScoreValues[1];
int score = int.Parse(highScoreValues[0]);
highScore.Add(new User(name, score));
}
}
GameTitle();
string highScoreStr = "HIGH SCORE";
string highScoreDelimiter = new string('-', 22);
Console.WriteLine("{0," + ((Console.WindowWidth / 2) + (highScoreStr.Length / 2)) + "}", highScoreStr);
Console.WriteLine("{0," + ((Console.WindowWidth / 2) + (highScoreDelimiter.Length / 2)) + "}", highScoreDelimiter);
foreach (var item in highScore.Reverse())
{
counter++;
Console.Write("{0," + Console.WindowWidth / 2.5 + "} | ", counter);
Console.WriteLine("{0} {1}", item.Score, item.Name);
if (counter >= 5)
{
break;
}
}
ConsoleKeyInfo enter = Console.ReadKey();
if (enter.Key == ConsoleKey.Enter)
{
Console.Clear();
DrawMenu();
}
else if (enter.Key == ConsoleKey.Escape)
{
Console.Clear();
DrawMenu();
}
}