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


C# SortedDictionary.ToList方法代码示例

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


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

示例1: GetServices

        public List<KeyValuePair<string, string>> GetServices()
        {
            SortedDictionary<string, string> mServices = new SortedDictionary<string, string>
      {
            {"PRIORITY_OVERNIGHT", "FedEx Priority Overnight"},
            {"STANDARD_OVERNIGHT", "FedEx Standard Overnight"}
      };

            return mServices.ToList();
        }
开发者ID:petrsvihlik,项目名称:Samples,代码行数:10,代码来源:FedExCarrier.cs

示例2: GetServices

        public List<KeyValuePair<string, string>> GetServices()
        {
            SortedDictionary<string, string> mServices = new SortedDictionary<string, string>
      {
            {"PRIORITY_OVERNIGHT", "Multi - FedEx Priority Overnight"},
            {"STANDARD_OVERNIGHT", "Multi - FedEx Standard Overnight"},
            {"UPS_NEXT_DAY_AIR_SAVER", "Multi - UPS Next Day Air Saver"},
            {"UPS_NEXT_DAY_AIR", "Multi - UPS Next Day Air"},
            {"USPSFirstClassMail", "Multi - USPS First-Class Mail"},
            {"USPSPriorityMail2-Day", "Multi - USPS Priority Mail 2-Day"},
            {"USPSPriorityMailExpress1-Day", "Multi - USPS Priority Mail Express 1-Day"}
      };

            return mServices.ToList();
        }
开发者ID:petrsvihlik,项目名称:Samples,代码行数:15,代码来源:MultiCarrier.cs

示例3: ButtonCreateCategoryWordDocuments_Click

        private void ButtonCreateCategoryWordDocuments_Click(object sender, RoutedEventArgs e)
        {
            var splitDataByDate = CheckBoxSplitDataByDate.IsChecked.Value;
            var normalize = CheckBoxNormaliseFeatures.IsChecked.Value;
            var dataSplitTime = Calendar.DisplayDate;
            var categoryFeaturesOutputTableName = TextBoxCategoryFeatures.Text;
            var categoryFeaturesOutputTable = database.GetCollection<BsonDocument>(categoryFeaturesOutputTableName + "Before " + dataSplitTime);
            var categoryFeaturesOutputTableTest = database.GetCollection<BsonDocument>(categoryFeaturesOutputTableName + "After " + dataSplitTime);
            var outputFolder = TextBoxCategoriesFilesFolder.Text;
            var output = new ArrayList<Tuple<BsonDocument[], string, List<string>>>();

            dynamic multiplier = 1;

            if (normalize)
            {
                multiplier = 1.0;
            }

            var users = usersTable.FindAll().ToArray();

            var categories = GetFoursquareVenueCategories();

            var features = new SortedDictionary<string, int[]>();

            foreach (var category in categories)
            {
                if (features.ContainsKey(category.Key)) continue;

                features.Add(category.Key, new []{0, 0});
            }

            var featuresList = features.ToList();

            File.WriteAllLines(Path.Combine(outputFolder, "CategoriesDescription.csv"), featuresList.ConvertAll(
                x =>
                {
                    foreach (var category in categories)
                    {
                        if (category.Key == x.Key)
                        {
                            return (featuresList.IndexOf(x) + 1)  +
                                "\t" +
                                category.Key +
                                "\t" +
                                category.Value;
                        }
                    }

                    return string.Empty;
                }));

            foreach(var user in users)
            {
                var userId = user["_id"].AsString;

                var filePath = Path.Combine(outputFolder, userId + ".txt");

                if (categoryFeaturesOutputTable.FindOne(Query.EQ("_id", userId)) != null) continue;

                foreach (var key in features.Keys)
                {
                    features[key][0] = 0;
                    features[key][1] = 0;
                }

                var categoryLDADocument = new List<string>();

                var checkins = checkinsTable.Find(Query.EQ("twitter_id", userId)).ToArray();

                var totalCount = new []{0, 0};

                foreach (var checkin in checkins)
                {
                    try
                    {
                        var venueCategories = checkin["data"]["checkin"]["venue"]["categories"].AsBsonArray;
                        var createdAt = UnitConversion.UnixTimeStampToDateTime(checkin["data"]["checkin"]["createdAt"].AsInt32);

                        foreach (var venueCategory in venueCategories)
                        {
                            var categoryId = venueCategory["id"].AsString;

                            if (dataSplitTime > createdAt || !splitDataByDate)
                            {
                                totalCount[0]++;

                                features[categoryId][0]++;
                            }
                            else
                            {
                                totalCount[1]++;

                                features[categoryId][1]++;
                            }

                            categoryLDADocument.Add(categoryId);
                        }
                    }
                    catch(Exception exc)
                    {
//.........这里部分代码省略.........
开发者ID:farseev,项目名称:mobility,代码行数:101,代码来源:MainWindow.xaml.cs

示例4: factorizeExpression


//.........这里部分代码省略.........
                    double val;

                    factorizationPriorities.TryGetValue(option, out val);

                    if (possibleOptions.ContainsKey(val))
                    {
                        possibleOptions.TryGetValue(val, out list);
                        list.Add(option);
                    }
                    else
                    {
                        list = new List<ConfigurationOption>();
                        list.Add(option);
                        possibleOptions.Add(val, list);
                    }
                }

                // Sort all options
                foreach (KeyValuePair<double, List<ConfigurationOption>> pair in possibleOptions)
                {
                    pair.Value.Sort(delegate (ConfigurationOption x, ConfigurationOption y)
                    {
                        int i, j;
                        counting.TryGetValue(x.Name, out i);
                        counting.TryGetValue(y.Name, out j);

                        return Math.Sign(j - i);
                    });
                }

                // Get the best option for factorization
                for (int i = possibleOptions.Count - 1; i >= 0 && !maxFound; i--)
                {
                    List<ConfigurationOption> list = possibleOptions.ToList()[i].Value;

                    for (int j = 0; j < list.Count && !maxFound; j++)
                    {
                        int count;
                        counting.TryGetValue(list[j].Name, out count);

                        if (count > 1)
                        {
                            maxFound = true;
                            max = list[j].Name;
                        }
                    }
                }

                List<Tuple<string, string>> others = new List<Tuple<string, string>>();
                List<Tuple<string, string>> varRest = new List<Tuple<string, string>>();

                foreach (Tuple<string, string> prt in expParts)
                {
                    string[] parts = prt.Item1.Split(' ');
                    int varPos = -1;
                    bool containsExactVar = false;

                    for (int i = 0; i < parts.Length && !containsExactVar; i++)
                    {
                        if (parts[i] == "log10(")
                        {
                            int bracketsCount = 1;

                            while (bracketsCount > 0)
                            {
                                i++;
开发者ID:ChristianKapfhammer,项目名称:SPLConqueror,代码行数:67,代码来源:MainWindow.cs

示例5: Main

 static void Main()
 {
     List<string> words = ReadWords(@"D:\Mirchev\SoftUni\Advanced-C#\06.StreamsAndFiles\03.WordCount\words.txt");
         SortedDictionary<string,int> result = new SortedDictionary<string, int>();
         foreach (var word in words)
         {
             int cnt = CountWords(word , @"D:\Mirchev\SoftUni\Advanced-C#\06.StreamsAndFiles\03.WordCount\text.txt" );
             result.Add(word, cnt);
         }
         List<KeyValuePair<string, int>> sortedRes = result.ToList();
         sortedRes.Sort((firstPair, nextPair) =>
         {
             return nextPair.Value.CompareTo(firstPair.Value);
         });
         StreamWriter results = new StreamWriter(@"D:\Mirchev\SoftUni\Advanced-C#\06.StreamsAndFiles\03.WordCount\result.txt");
         foreach (var sorted in sortedRes)
         {
             results.WriteLine("{0} - {1}", sorted.Key, sorted.Value);
         }
         results.Close();
 }
开发者ID:mkmirchev,项目名称:CSharp-Advanced,代码行数:21,代码来源:03.WordCount.cs


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