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


C# HashSet.OrderByDescending方法代码示例

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


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

示例1: PollMessages

        private void PollMessages(object state)
        {
            var copyOfCachedMessages = new HashSet<Message>(_messageCache);
            var sinceId = copyOfCachedMessages.OrderByDescending(x => x.Created).First().IdValue;
            var messageService = CreateBaseMessageService.Invoke();
            var messages = messageService.GetMessagesSinceAsync(sinceId).Result.ToList();

            if (messages.Count == 0)
                return;

            foreach (var message in messages)
            {
                copyOfCachedMessages.Add(message);
            }

            if (copyOfCachedMessages.Count > MaxCacheCount)
            {
                var reducedCachedMessages = 
                    copyOfCachedMessages
                        .OrderByDescending(x => x.Created)
                        .Take(MaxCacheCount);

                copyOfCachedMessages.Clear();

                foreach (var message in reducedCachedMessages)
                {
                    copyOfCachedMessages.Add(message);
                }
            }

            lock (_padlock)
            {
                _messageCache = copyOfCachedMessages;
            }
        }
开发者ID:dustinmoris,项目名称:JuniorDoctorsStrike,代码行数:35,代码来源:CachedMessageService.cs

示例2: WriteListings

        public void WriteListings()
        {
            HashSet<ArchiveListing> set = new HashSet<ArchiveListing>();
            foreach (ArchiveListing listing in _set)
            {
                ArchiveListing item = listing;
                while (item != null && set.Add(item))
                    item = item.Parent;
            }

            Action<ArchiveListing> writer;
            switch (InteractionService.GamePart)
            {
                case FFXIIIGamePart.Part1:
                    writer = ArchiveListingWriterV1.Write;
                    break;
                case FFXIIIGamePart.Part2:
                    writer = ArchiveListingWriterV2.Write;
                    break;
                default:
                    throw new NotSupportedException(InteractionService.GamePart.ToString());
            }

            foreach (ArchiveListing listing in set.OrderByDescending(l => l.Accessor.Level))
                writer(listing);
        }
开发者ID:truongan012,项目名称:Pulse,代码行数:26,代码来源:UiInjectionManager.cs

示例3: WriteListings

        public void WriteListings()
        {
            HashSet<ArchiveListing> set = new HashSet<ArchiveListing>();
            foreach (ArchiveListing listing in _set)
            {
                ArchiveListing item = listing;
                while (item != null && set.Add(item))
                    item = item.Parent;
            }

            foreach (ArchiveListing listing in set.OrderByDescending(l => l.Accessor.Level))
                ArchiveListingWriter.Write(listing);
        }
开发者ID:kidaa,项目名称:Pulse,代码行数:13,代码来源:UiInjectionManager.cs

示例4: GetTags

        internal IEnumerable<RepositoryCommitModel> GetTags(string name, int page, int p, out string referenceName, out int totalCount)
        {
            var commit = GetCommitByName(name, out referenceName);
            if (commit == null)
            {
                totalCount = 0;
                return Enumerable.Empty<RepositoryCommitModel>();
            }
            var tags = _repository.Tags;
            var commits = new HashSet<RepositoryCommitModel>(AnonymousComparer.Create<RepositoryCommitModel>((x, y) => x.ID == y.ID, obj => obj.ID.GetHashCode()));
            foreach (var tag in tags)
            {
                var c = _repository.Lookup(tag.Target.Id) as Commit;
                commits.Add(ToModel(c));

            }
            totalCount = commits.Count();

            return commits.OrderByDescending(x => x, (x, y) => x.Date.CompareTo(y.Date));
        }
开发者ID:Guzhongren,项目名称:Bonobo-Git-Server,代码行数:20,代码来源:RepositoryBrowser.cs

示例5: GetNearestNeighbors

        public List<LSHashTweet> GetNearestNeighbors(LSHashTweet tweet, int n)
        {
            if (_content.Count == 0)
                return new List<LSHashTweet>();

            HashSet<LSHashTweet> candidates = new HashSet<LSHashTweet>();
            List<long> wordIDs = tweet.Vector.GetItemIDs();
            foreach (long wordID in wordIDs)
            {
                if (_wordIndex.ContainsKey(wordID))
                {
                    foreach (LSHashTweet candidate in _wordIndex[wordID])
                        candidates.Add(candidate);
                }
            }

            if (candidates.Count == 0)
                return new List<LSHashTweet>();

            return candidates.OrderByDescending(t => t.Vector * tweet.Vector).Take(n).ToList();
        }
开发者ID:malimu,项目名称:CrisisTracker,代码行数:21,代码来源:LSHashTweetHistory.cs

示例6: Main

 static void Main(string[] args)
 {
     Console.WriteLine(11111);
     //SortedSet<TestSort> s = new SortedSet<TestSort>(new TestSort[] {new TestSort {Name="bar", Age=1}});
     HashSet<TestSort> s = new HashSet<TestSort>();
     s.Add(  new TestSort {Name="foo6", Age=6} );
     s.Add(  new TestSort {Name="bar1", Age=1} );
     s.Add(  new TestSort {Name="hoge5", Age=5} );
     //SortedSet<TestSort> s = new SortedSet<TestSort>(new TestSort[] {
     //  new TestSort {Name="foo", Age=6},
     //  new TestSort {Name="bar", Age=1},
     //  new TestSort {Name="hoge", Age=5},
     //});
     Console.WriteLine(22222);
     Console.WriteLine(s);
     IEnumerable<TestSort>new_s = s.OrderByDescending(pet => pet.Age);
     foreach (TestSort ts in new_s)
     {
       Console.WriteLine(ts.Name);
     }
 }
开发者ID:SpringMT,项目名称:study,代码行数:21,代码来源:SortedSetTest.cs

示例7: GetScores

		public static ulong[] GetScores()
		{
			var scores = new HashSet<ulong>();

			// row scores.
			for (var col = 0; col < 4; col++)
			{
				for (var row = 0; row < 6; row++)
				{
					ulong line = 0x0F;
					line <<= col + (row << 3);
					scores.Add(line);
				}
			}

			// column scores.
			for (var col = 0; col < 7; col++)
			{
				for (var row = 0; row < 3; row++)
				{
					ulong line = 0x01010101;
					line <<= col + (row << 3);
					scores.Add(line);
				}
			}
			// diagonal scores.
			for (var col = 0; col < 4; col++)
			{
				for (var row = 0; row < 3; row++)
				{
					ulong dig0 = 0x08040201;
					ulong dig1 = 0x01020408;
					dig0 <<= col + (row << 3);
					dig1 <<= col + (row << 3);
					scores.Add(dig0);
					scores.Add(dig1);
				}
			}
			return scores.OrderByDescending(s => s).ToArray();
		}
开发者ID:Corniel,项目名称:AIGames.FourInARow.TheDaltons,代码行数:40,代码来源:Field.Masks.cs

示例8: WriteToScoreBoard

        /// <summary>
        /// Writes a player to the scoreboard database.
        /// </summary>
        /// <param name="player">PLayer to be written.</param>
        public void WriteToScoreBoard(IPlayer player)
        {
            ICollection<IPlayer> currentScoreBoard = new HashSet<IPlayer>();
            currentScoreBoard = this.ReadScoreboard();

            bool reorder = true;
            foreach (var currPlayer in currentScoreBoard.Where(cp => cp.Name == player.Name))
            {
                if (currPlayer.Score <= player.Score)
                {
                    currPlayer.Score = player.Score;
                    reorder = false;
                }
            }

            var sortedScoreBoard = currentScoreBoard;
            if (reorder)
            {
                currentScoreBoard.Add(player);
                sortedScoreBoard = currentScoreBoard.OrderByDescending(pl => Convert.ToInt32(pl.Score)).ThenBy(pl => pl.Name).ToList();
            }

            DataSerialization.WriteToFile(sortedScoreBoard, FileNames.scoreboard);
        }
开发者ID:HQC-Team-Hangman-4,项目名称:Hangman-4,代码行数:28,代码来源:ScoreBoardDatabase.cs

示例9: FindMostCommonWord

 /// <summary>
 /// Finds the most common word
 /// </summary>
 /// <param name="rank">How far down the list you want to go. for example if you wanted the 4th equal words you's pass 3</param>
 /// <returns>a list of either one or more strings that represtent the word or words equally tied at that rank</returns>
 public List<string> FindMostCommonWord(int rank)
 {
     var groupedWords = Words.GroupBy(e => e.WordText) // this linq statement groups and counts words based on their length
         .Select(group => new { Value = group.Key, Count = group.Count() })
         .OrderByDescending(x => x.Count)
         .ToList();
     ISet<int> commoness = new HashSet<int>();
     foreach (var item in groupedWords)
     {
         commoness.Add(item.Count); // add the count of each word to the set
     }
     int i = commoness.OrderByDescending(e => e).ToList()[rank]; // this gets the number of times the most common word occured
     List<string> commonWords = new List<string>();
     foreach (var word in groupedWords.Where(e => e.Count == i)) // this filters for words that occured that many times
     {
         commonWords.Add(word.Value);
     }
     return commonWords;
 }
开发者ID:thomashorrobin,项目名称:SignalCodeChallenge,代码行数:24,代码来源:Text.cs

示例10: RemoveActivities

 public void RemoveActivities(System.Collections.IList items)
 {
     var indexes = new HashSet<int>();
     foreach (Activity activity in items) {
         indexes.Add(this.Activities.IndexOf(activity));
     }
     foreach (int index in indexes.OrderByDescending(i=>i))
     {
         this.Activities.RemoveAt(index);
     }
 }
开发者ID:rbrother,项目名称:TimeTracker,代码行数:11,代码来源:TimeTrackerData.cs

示例11: UpdateBehaviorTreeView

        private void UpdateBehaviorTreeView()
        {
            behaviorTreeView.BeginUpdate();
            behaviorTreeView.Nodes.Clear();

            var rootKeys = new HashSet<string>(BT.Roots().Select(r => r.Key));
            foreach (var key in PublicRoots)
                rootKeys.Add(key);

            foreach (var key in rootKeys.OrderByDescending(k => PublicRoots.Contains(k)).ThenBy(k => k))
            {
                Behavior root;
                if (BT.Tree.TryGetValue(key, out root))
                {
                    var btPath = new BTPath { Path = new List<Behavior>() };
                    var newNode = AddNode(btPath, root, behaviorTreeView.Nodes);
                    btPath.Path.Add(root);
                    Expand(newNode, btPath);

                    if (expandedPaths.Contains(newNode.Tag.ToString()))
                        newNode.Expand();
                }
            }
            behaviorTreeView.EndUpdate();

            if (configParser.Errors.Count > 0 || analyzer.Errors.Count > 0)
            {
                errorListBox.BeginUpdate();
                errorListBox.Items.Clear();

                foreach (var error in configParser.Errors)
                    errorListBox.Items.Add(error);
                foreach (var error in analyzer.Errors)
                    errorListBox.Items.Add(error);

                errorListBox.EndUpdate();

                errorListBox.Show();
                errorLabel.Show();
            }
            else
            {
                errorListBox.Hide();
                errorLabel.Hide();
            }

            overviewTooltipStatuslabel.Text = string.Format("{0} files, {1} nodes", layers.Count(l => l.Enabled),
                BT.Tree.Count);

            expandedPaths.Clear();
        }
开发者ID:RossM,项目名称:AIBTExplorer,代码行数:51,代码来源:BTViewer.cs

示例12: GetAllVariablesByDescending

 private void GetAllVariablesByDescending()
 {
     var variables = new HashSet<Variable>();
     foreach (var equation in _equationsList)
     {
         equation.MoveAllVarsToLeft();
         foreach (var expression in equation.LeftPart)
         {
             var variable = expression.Variable;
             if (!variable.Equals(Variable.NULL))
                 variables.Add(variable);
         }
     }
     _variablesList = variables.OrderByDescending(x => x.Name).ToList();
 }
开发者ID:qqudesnik,项目名称:Gauss,代码行数:15,代码来源:SystemOfEquations.cs

示例13: FindLongestWord

 /// <summary>
 /// This gets the longest words excluding punctuation 
 /// </summary>
 /// <param name="rank">How far down the list you want to go. for example if you wanted the 4th equal words you's pass 3</param>
 /// <returns>a list of either one or more strings that represtent the word or words equally tied at that rank</returns>
 public List<string> FindLongestWord(int rank)
 {
     ISet<int> wordLengths = new HashSet<int>(); // a set is needed for this because we need to avoid duplication i.e. two words of length 13 should only be counted once
     foreach (Word word in Words)
     {
         wordLengths.Add(word.WordLength); // add the lengths of all words to the set
     }
     List<int> sortedWordLengths = wordLengths.OrderByDescending(e => e).ToList(); // sort them from highest to lowest so we can fetch highest, 3rd highest, etc
     List<string> longestWords = new List<string>();
     int wordLength = 0;
     try
     {
         wordLength = sortedWordLengths[rank]; // try to use what has been passed in with the rank parameter but it might be out of range
     }
     catch (IndexOutOfRangeException)
     {
         wordLength = sortedWordLengths.Last(); // if out of range just call the last one (this doesn't help if there's nothing in the list though)
     }
     foreach (Word word in Words.Where(e => e.WordLength == wordLength)) // filter words by their length, the length to use is calc using rank
     {
         longestWords.Add(word.WordText);
     }
     return longestWords;
 }
开发者ID:thomashorrobin,项目名称:SignalCodeChallenge,代码行数:29,代码来源:Text.cs

示例14: TargetWeights

        private static IEnumerable<Obj_AI_Hero> TargetWeights(List<Obj_AI_Hero> targets)
        {
            try
            {
                foreach (var item in WeightedItems.Where(w => w.Weight > 0))
                {
                    item.UpdateMinMax(targets);
                }

                var targetsList = new HashSet<Target>();
                var multiplicator =
                    _menu.Item(_menu.Name + ".weights.heroes.weight-multiplicator").GetValue<Slider>().Value;
                foreach (var target in targets)
                {
                    var tmpWeight = WeightedItems.Where(w => w.Weight > 0).Sum(w => w.CalculatedWeight(target));
                    if (_menu != null)
                    {
                        tmpWeight +=
                            (_menu.Item(_menu.Name + ".weights.heroes." + target.ChampionName).GetValue<Slider>().Value *
                             _averageWeight + 0.1f) * multiplicator;
                    }

                    targetsList.Add(new Target(target, tmpWeight));
                }
                return targetsList.Count > 0 ? targetsList.OrderByDescending(t => t.Weight).Select(t => t.Hero) : null;
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return null;
        }
开发者ID:lukasi273,项目名称:SFX-5.12-update,代码行数:32,代码来源:TargetSelector.cs

示例15: ShowAchievementUnlocked

        private static void ShowAchievementUnlocked(Achievement a)
        {
            var content = new GUIContent("ACHIEVEMENT UNLOCKED\n" + a.Title, GetIcon ());

            // Find the best window to display this on
            var allWindows = new HashSet<EditorWindow>((EditorWindow[])Resources.FindObjectsOfTypeAll(typeof(EditorWindow)));
            allWindows.RemoveWhere (IsEditorWindowHiddenTab);

            var targetWindow = allWindows.OrderByDescending(w => Mathf.Pow(w.position.width, WidthBias) * w.position.height).FirstOrDefault();
            if(targetWindow)
            {
            targetWindow.ShowNotification(content);
            }

            Debug.Log (string.Format("ACHIEVEMENT UNLOCKED: {0}\n{1}\n\n\n\n\n", a.Title, a.Description));
        }
开发者ID:richard-fine,项目名称:unity-achievements,代码行数:16,代码来源:Achievements.cs


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