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


C# SortedSet.Reverse方法代码示例

本文整理汇总了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;
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:10,代码来源:CardCollect.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++;
            }
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:23,代码来源:SortedSetSpecificTests.cs

示例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 = "&nbsp;";
				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;
			}
//.........这里部分代码省略.........
开发者ID:plntxt,项目名称:dasblog,代码行数:101,代码来源:MonthViewBox.ascx.cs

示例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;
        }
开发者ID:Bleizard,项目名称:ITMO,代码行数:36,代码来源:PolyphaseMergeSort.cs

示例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();
            }
        }
开发者ID:rhynodegreat,项目名称:BulletSharpPInvoke,代码行数:78,代码来源:DefaultParser.cs

示例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();
            }
        }
开发者ID:evgeni-tsn,项目名称:Advanced-CSharp-Teamwork-Popcorn,代码行数:44,代码来源:Executioner.cs


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