• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# OrderedMultiDictionary类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中OrderedMultiDictionary的典型用法代码示例。如果您正苦于以下问题:C# OrderedMultiDictionary类的具体用法?C# OrderedMultiDictionary怎么用?C# OrderedMultiDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OrderedMultiDictionary类属于命名空间,在下文中一共展示了OrderedMultiDictionary类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            var products = new OrderedMultiDictionary<double, string>(true);
            int numberOfLines = int.Parse(Console.ReadLine());
            string line = string.Empty;
            string productName = string.Empty;
            double productPrice = 0;

            for (int i = 0; i < numberOfLines; i++)
            {
                line = Console.ReadLine();

                var parts = line.Split(' ');

                productName = parts[0].Trim();
                productPrice = double.Parse(parts[1].Trim());

                products.Add(productPrice, productName);
            }

            var limits = Console.ReadLine().Split(' ');
            double lowerLimit = double.Parse(limits[0].Trim());
            double upperLimit = double.Parse(limits[1].Trim());
            var productsInRange = products.Range(lowerLimit, true, upperLimit, true);

            foreach (var productInRange in productsInRange)
            {
                Console.WriteLine("{0} {1}", productInRange.Key, productInRange.Value);
            }
        }
开发者ID:ivan4otopa,项目名称:SoftUni,代码行数:32,代码来源:ProductsInPriceRange.cs


示例2: Main

        public static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            var eventCount = int.Parse(Console.ReadLine());
            var datesAndEvents = new OrderedMultiDictionary<DateTime, string>(true);
            for (int i = 0; i < eventCount; i++)
            {
                var currentEvent = Console.ReadLine();
                var token = currentEvent.Split('|');
                var date = DateTime.Parse(token[1].Trim());
                var name = token[0].Trim();
                datesAndEvents.Add(date, name);
            }

            var queryNumber = int.Parse(Console.ReadLine());
            for (int i = 0; i < queryNumber; i++)
            {
                var query = Console.ReadLine().Split('|');
                var startDate = DateTime.Parse(query[0].Trim());
                var endDate = DateTime.Parse(query[1].Trim());
                var queryData = datesAndEvents.Range(startDate, true, endDate, true);
                Console.WriteLine(queryData.KeyValuePairs.Count);
                foreach (var e in queryData)
                {
                    foreach (var name in e.Value)
                    {
                        Console.WriteLine("{0} | {1:dd-MMM-yyyy}", name, e.Key);
                    }
                }
            }
        }
开发者ID:peterkirilov,项目名称:SoftUni-1,代码行数:32,代码来源:EventsInGivenRange.cs


示例3: GenerateArticles

        private static OrderedMultiDictionary<int, Article> GenerateArticles(int count)
        {
            var barcodes = new HashSet<string>();

            Console.Write("Generating barcodes...");
            while (barcodes.Count < count)
            {
                var barcode = RandomGenerator.GetRandomString(BarcodeLength);
                barcodes.Add(barcode);
                if (barcodes.Count % (count / 10) == 0)
                {
                    Console.Write('.');
                }
            }

            Console.Write("\n\nGenerating articles...");
            var articles = new OrderedMultiDictionary<int, Article>(true);
            foreach (var barcode in barcodes)
            {
                var vendor = RandomGenerator.GetRandomString(5);
                var title = RandomGenerator.GetRandomString(7);
                var price = RandomGenerator.GeneratRandomNumber(0, count);
                var article = new Article(barcode, vendor, title, price);
                articles.Add(price, article);
                if (articles.Count % (count / 10) == 0)
                {
                    Console.Write('.');
                }
            }

            Console.WriteLine();
            return articles;
        }
开发者ID:bstaykov,项目名称:Telerik-DSA,代码行数:33,代码来源:Program.cs


示例4: Main

        static void Main()
        {
            var mDict = new OrderedMultiDictionary<decimal, Product>(true);
            string[] productNames =
            {
                "Toy", "Food", "Car", "TV", "Computer", "Refrigerator", 
                "Bicylce", "Skateboard", "Bag", "EReader", "Phone", "Guitar", 
            };
            var rand = new Random();
            for (int i = 0; i < 500000; i++)
            {
                decimal price = rand.Next(1, 10000);
                string name = productNames[rand.Next(0, productNames.Length)];
                mDict.Add(price, new Product(name, price));
            }

            var productsInRange = mDict.Range(25, true, 30, true);
            Console.WriteLine("Total products in price range: {0}", productsInRange.KeyValuePairs.Count);
            Console.WriteLine("==================================");
            foreach (var products in productsInRange)
            {
                Console.WriteLine("Price: {0}, Count: {1}", products.Key, productsInRange[products.Key].Count);
                Console.WriteLine("Products: {0}", string.Join(", ", products.Value));
                Console.WriteLine("==================================");
            }
        }
开发者ID:pkanev,项目名称:Data.Structures,代码行数:26,代码来源:ProductsInPriceRange.cs


示例5: Main

        static void Main()
        {
            var products = new OrderedMultiDictionary<decimal, Product>(true);

            Console.Write("Creating and adding products");
            for (int i = 0; i < 1000000; i++)
            {
                products.Add(
                    (i + 1) % 50 + (decimal)i / 100,
                    new Product(
                    "Product #" + (i + 1),
                    ((i + 1) % 50 + (decimal)i / 100),
                    "Vendor#" + i % 50000,
                    null));
                if (i % 1000 == 0)
                {
                    Console.Write(".");
                }
            }

            Console.WriteLine();

            var productsInPricerangeFrom10To11 = products.Range(10M, true, 11M, true);
            var productsInPricerangeFrom15To25 = products.Range(15M, true, 25M, true);
            var productsInPricerangeFrom30To35 = products.Range(30M, true, 35M, true);

            Console.WriteLine("Products with price between 10 and 11: " + productsInPricerangeFrom10To11.Count);
            Console.WriteLine("Products with price between 15 and 25: " + productsInPricerangeFrom15To25.Count);
            Console.WriteLine("Products with price between 30 and 35: " + productsInPricerangeFrom30To35.Count);
        }
开发者ID:dtopalov,项目名称:DSA,代码行数:30,代码来源:CompanyArticlesOperations.cs


示例6: Main

        static void Main(string[] args)
        {
            OrderedMultiDictionary<decimal, Article> articles = 
                new OrderedMultiDictionary<decimal, Article>(true);

            articles.Add(12.43m, new Article("Choco", "123124234", "Milka", 12.43m));
            articles.Add(14.43m, new Article("Natural", "123124234", "Milka", 14.43m));
            articles.Add(15.43m, new Article("Raffy", "123124234", "Milka", 15.43m));
            articles.Add(17.43m, new Article("Milk", "123124234", "Milka", 17.43m));
            articles.Add(18.43m, new Article("Sugar", "123124234", "Milka", 18.43m));
            articles.Add(19.43m, new Article("Bread", "123124234", "Milka", 19.43m));
            articles.Add(20.43m, new Article("Susam", "123124234", "Milka", 20.43m));
            articles.Add(23.43m, new Article("Paper", "123124234", "Milka", 23.43m));
            articles.Add(25.43m, new Article("Grape", "123124234", "Milka", 25.43m));
            articles.Add(54.43m, new Article("Banana", "123124234", "Milka", 54.43m));
            articles.Add(43.43m, new Article("Orange", "123124234", "Milka", 43.43m));
            articles.Add(32.43m, new Article("Melon", "123124234", "Milka", 32.43m));
            articles.Add(24.43m, new Article("WaterMelon", "123124234", "Milka", 24.43m));
            articles.Add(76.43m, new Article("Junk", "123124234", "Milka", 76.43m));

            var rangeArticles = articles.Range(20m, true, 35m, true);
            foreach (var article in rangeArticles)
            {
                foreach (var item in article.Value)
                {
                    Console.WriteLine(item);
                }
            }
        }
开发者ID:VyaraGGeorgieva,项目名称:TelerikAcademy,代码行数:29,代码来源:Program.cs


示例7: ReadStudentsAndCoursesInput

        private static void ReadStudentsAndCoursesInput()
        {
            // using OrderedMultiDictionary because courses names can repeat
            // in SortedDictionary this is not possible

            // for every course we add the students which attend this course
            // and they are sorted by last name and then by first name (look at the Student class)
            courses = new OrderedMultiDictionary<string, Student>(true);

            StreamReader reader = new StreamReader("students.txt");

            using (reader)
            {
                string line = reader.ReadLine();

                while (line != null)
                {
                    var splitted = line.Split('|');

                    string studentFN = splitted[0].Trim();
                    string studentLN = splitted[1].Trim();
                    string courseName = splitted[2].Trim();

                    courses.Add(courseName, new Student(studentFN, studentLN));

                    line = reader.ReadLine();
                }
            }
        }
开发者ID:jesusico83,项目名称:Telerik,代码行数:29,代码来源:StudentsAndCourses.cs


示例8: CreateScoreboardString

        public static string CreateScoreboardString(OrderedMultiDictionary<int, string> statistics)
        {
            int resultsCount = Math.Min(5, statistics.Count);
            int counter = 0;

            StringBuilder scoreboard = new StringBuilder();

            scoreboard.AppendLine("Scoreboard:");

            foreach (var result in statistics)
            {
                if (counter == resultsCount)
                {
                    break;
                }
                else
                {
                    counter++;
                    var format = String.Format("{0}. {1} --> {2} moves", resultsCount, result.Value, result.Key);
                    scoreboard.AppendLine(format);
                }
            }

            return scoreboard.ToString();
        }
开发者ID:TishoAngelov,项目名称:TelerikAcademy,代码行数:25,代码来源:ConsoleIOFacade.cs


示例9: Main

    static void Main()
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

        var events = new OrderedMultiDictionary<DateTime, string>(true);
        int eventsCount = int.Parse(Console.ReadLine());
        for (int i = 0; i < eventsCount; i++)
        {
            string[] eventParams = Console.ReadLine().Split('|');
            string eventName = eventParams[0].Trim();
            var eventTime = DateTime.Parse(eventParams[1].Trim());
            events.Add(eventTime, eventName);
        }

        int rangesCount = int.Parse(Console.ReadLine());
        for (int i = 0; i < rangesCount; i++)
        {
            string[] timeParams = Console.ReadLine().Split('|');
            var startTime = DateTime.Parse(timeParams[0].Trim());
            var endTime = DateTime.Parse(timeParams[1].Trim());

            var filteredEvents = events.Range(startTime, true, endTime, true);
            Console.WriteLine(filteredEvents.Values.Count);
            foreach (var timeEventsPair in filteredEvents)
            {
                foreach (string eventName in timeEventsPair.Value)
                {
                    Console.WriteLine("{0} | {1}", eventName, timeEventsPair.Key);
                }
            }
        }
    }
开发者ID:vangelov-i,项目名称:Fundamentals,代码行数:32,代码来源:EventsInGivenDateRange.cs


示例10: Main

    /* 2. A large trade company has millions of articles, each described
       by barcode, vendor, title and price. Implement a data structure to
       store them that allows fast retrieval of all articles in given price
       range [x...y].

       Hint: use OrderedMultiDictionary<K,T> from Wintellect's Power
       Collections for .NET.
     * */
    static void Main(string[] args)
    {
        // What's there to "implement"?
        // That's exactly what OrderedMultiDictionary was made for.

        // input generator in bin\debug\generator.cs

        var products = new OrderedMultiDictionary<decimal, string>(true);

        foreach (var line in File.ReadLines("products.txt").Skip(1))
        {
            var split = line.Split('|');
            products.Add(decimal.Parse(split[0]), split[1]);
        }

        foreach (var line in File.ReadLines("commands.txt"))
        {
            Console.WriteLine("Command: " + line);
            var split = line.Split('|');

            var first = decimal.Parse(split[0]);
            var second = decimal.Parse(split[1]);

            var matching = products.Range(Math.Min(first, second), true,
                                          Math.Max(first, second), true);

            Console.WriteLine(string.Join(", ", matching));
            Console.WriteLine();
            Console.WriteLine("Press Ctrl+C to quit, or any other key to continue...");
            Console.ReadLine();
        }
    }
开发者ID:staafl,项目名称:ta-hw-dsa,代码行数:40,代码来源:program.cs


示例11: Main

        public static void Main(string[] args)
        {
            var productsAndPrices = new OrderedMultiDictionary<int, string>(true);
            var rng = new Random();
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (int i = 0; i < 500000; i++)
            {
                var product = GenerateProduct(rng, i);
                var tokens = product.Split('|');
                var name = tokens[0].Trim();
                var price = int.Parse(tokens[1].Trim());
                productsAndPrices.Add(price, name);
            }

            Console.WriteLine("Seed time: " + stopwatch.Elapsed);
            stopwatch.Restart();
            Console.WriteLine("Query Start");
            var printed = new Set<int>();
            for (int i = 0; i < 10000; i++)
            {
                var startPrice = rng.Next(0, 100001);
                var endPrice = rng.Next(startPrice, 100001);
                var productsInRange = productsAndPrices.Range(startPrice, true, endPrice, true).Take(20);
                var count = productsInRange.Count();
                if (!printed.Contains(count))
                {
                    Console.WriteLine("{0} to {1} -> {2}", startPrice, endPrice, count);
                    printed.Add(count);
                }
            }

            Console.WriteLine("Query time: " + stopwatch.Elapsed);
            Console.WriteLine("All Done");
        }
开发者ID:peterkirilov,项目名称:SoftUni-1,代码行数:35,代码来源:ProductsInPriceRange.cs


示例12: ShoppingCenter

 public ShoppingCenter()
 {
     this.productsByProducer = new Dictionary<string, Bag<Product>>();
     this.productsByName = new Dictionary<string, Bag<Product>>();
     this.productsByNameAndProducer = new Dictionary<Tuple<string, string>, Bag<Product>>();
     this.productsByPrice = new OrderedMultiDictionary<decimal, Product>(true);
 }
开发者ID:pavelilchev,项目名称:HomeWorks,代码行数:7,代码来源:ShoppingCenter.cs


示例13: ShoppingCenter

 public ShoppingCenter()
 {
     productsByName = new MultiDictionary<string, Product>(true);
     nameAndProducer = new MultiDictionary<string, Product>(true);
     productsByPrice = new OrderedMultiDictionary<decimal, Product>(true);
     productsByProducer = new MultiDictionary<string, Product>(true);
 }
开发者ID:ekostadinov,项目名称:CoursesProjects,代码行数:7,代码来源:ShoppingCenter.cs


示例14: Main

        static void Main()
        {
            const bool areDublicationOfValuesAllawed = true;

            OrderedMultiDictionary<decimal, Articule> articules =
                new OrderedMultiDictionary<decimal, Articule>(areDublicationOfValuesAllawed);

            PopulateArticules(articules);
            
            Stopwatch sw = new Stopwatch();
            sw.Start();
            var result = articules.Range(200m, true, 220m, true);
            sw.Stop();
            

            foreach (var record in result)
            {
                Console.BufferWidth = 160;
                foreach (var value in record.Value) 
                {
                    Console.WriteLine(value);
                }
            }

            Console.WriteLine("Elapsed time to find: {0}", sw.Elapsed);
        }
开发者ID:NikolayKostadinov,项目名称:Homeworks,代码行数:26,代码来源:ArticlesInGivenPriceRange.cs


示例15: GenerateProductList

    /// <summary>
    /// Read file and add element to the product list (price with barcode, vendor and title)
    /// </summary>
    /// <param name="file">File name</param>
    /// <exception cref="ArgumentNullException">
    /// If file name is null or white space</exception>
    /// <remarks>Use UTF-8 encoding</remarks>
    /// <returns>Created product list</returns>
    public static OrderedMultiDictionary<double, string> GenerateProductList(string file)
    {
        if (string.IsNullOrWhiteSpace(file))
        {
            throw new ArgumentNullException(
                "Invalid input! File name cannot be null or white space.");
        }

        OrderedMultiDictionary<double, string> productList =
            new OrderedMultiDictionary<double, string>(true);
        StreamReader reader = new StreamReader(file, Encoding.GetEncoding("UTF-8"));
        using (reader)
        {
            string line = reader.ReadLine();
            while (line != null)
            {
                string[] content = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                string barcode = content[0].Trim();
                string vendor = content[1].Trim();
                string title = content[2].Trim();
                double price = double.Parse(content[3].Trim());
                productList.Add(price,
                    string.Format("Barcode: {0} Vendor: {1}  Title: {2}", barcode, vendor, title));
                line = reader.ReadLine();
            }
        }

        return productList;
    }
开发者ID:vasilkrvasilev,项目名称:DataStructuresAlgorithms,代码行数:37,代码来源:CompanyList.cs


示例16: Main

    static void Main()
    {
        OrderedMultiDictionary<string, Student> students = new OrderedMultiDictionary<string, Student>(true);

        using (StreamReader reader = new StreamReader(@"../../Students.txt"))
        {
            string line = reader.ReadLine();
            while (line != null)
            {
                string[] arguments = ParseInput(line);
                if (arguments.Length == 3)
                {
                    string firstName = arguments[0].Trim();
                    string lastName = arguments[1].Trim();
                    string course = arguments[2].Trim();

                    students.Add(course, new Student(firstName, lastName));
                }

                line = reader.ReadLine();
            }
        }

        foreach (var course in students)
        {
            Console.WriteLine("{0}: {1}", course.Key, string.Join(", ", course.Value));
        }
    }
开发者ID:bahtev,项目名称:TelerikAcademy,代码行数:28,代码来源:Program.cs


示例17: Main

        public static void Main()
        {
            var streamReader = new StreamReader("../../students.txt");
            var multiDiuctionary = new OrderedMultiDictionary<Course, Student>(true);

            using (streamReader)
            {
                string line = streamReader.ReadLine();
                while (line != null)
                {
                    string[] parameters = line.Split(new char[] { ' ', '|' }, StringSplitOptions.RemoveEmptyEntries);

                    string courseName = parameters[2];
                    var course = new Course(courseName);

                    string firstName = parameters[0];
                    string lastName = parameters[1];
                    var student = new Student(firstName, lastName);

                    multiDiuctionary.Add(course, student);

                    line = streamReader.ReadLine();
                }
            }

            PrintCourses(multiDiuctionary);
        }
开发者ID:antonpopov,项目名称:Data-Structures-and-Algorithms,代码行数:27,代码来源:Startup.cs


示例18: Main

        static void Main()
        {
            Article[] articles = {new Article(0999311,"GeorgiIvanovOOD","Gloves",10.56M),
                                     new Article(09945311,"GeorgiIvanovOOD","Hats",8.00M),
                                     new Article(45945311,"ETIliev","Bags",18.00M),
                                     new Article(45947311,"ETIliev","Shoes",18.00M),
                                     new Article(13447311,"ETIliev","Socks",3.99M),
                                     new Article(13412570,"ETDimitrov","BaseballBats",23.99M)};

            OrderedMultiDictionary<decimal, Article> catalog = new OrderedMultiDictionary<decimal, Article>(true);

            foreach (var article in articles)
            {
                catalog.Add(article.Price, article);
            }

            var pricesRange = catalog.FindAll(x => x.Key >= 10 && x.Key <= 20);
            foreach (var item in pricesRange)
            {
                string items = "";
                int count = 0;
                foreach (var article in item.Value)
                {
                    count += 1;
                    items += "article"+count+": "+ article.Title + " " + article.Vedndor + " " + article.Barcode+";\n";
                }

                Console.WriteLine("Price: {0} - articles: {1}",
                    item.Key,items);
            }
        }
开发者ID:Jarolim,项目名称:TelerikAcademy-1,代码行数:31,代码来源:Program.cs


示例19: Main

        public static void Main()
        {
            OrderedMultiDictionary<double, Article> articles = new OrderedMultiDictionary<double, Article>(true);

            int range = 10000;
            for (int i = 0; i < range; i++)
            {
                var article = new Article("barcode" + i, "vendor" + i, "title" + i, i);
                articles.Add(article.Price, article);
            }

            int from = 5000;
            int to = 5040;

            //Make some duplications
            for (int i = from; i < to - 30; i++)
            {
                var article = new Article("newBarcode" + i, "newVendor" + i, "newTitle" + i, i);
                articles.Add(article.Price, article);
            }

            var articlesInGivenRange = articles.Range(from, true, to, true);
            foreach (var article in articlesInGivenRange)
            {
                foreach (var item in article.Value)
                {
                    Console.WriteLine("Title: {0}, Vendor: {1}, Barcode: {2}, Price: {3}",
                    item.Title, item.Vendor, item.Barcode, item.Price);
                }
                Console.WriteLine();
            }
        }
开发者ID:Nottyy,项目名称:TelerikAcademy,代码行数:32,代码来源:TestEntry.cs


示例20: Main

        public static void Main()
        {
            var reader = new StreamReader("../../Students.txt");

            var dictionary = new OrderedMultiDictionary<string, Student>(true);

            string line = reader.ReadLine();

            while (line != null)
            {
                string[] splitedLine = line.Split(new char[]{'|'}, StringSplitOptions.RemoveEmptyEntries).Select(word => word.Trim()).ToArray();

                Student student = new Student(splitedLine[0], splitedLine[1]);
                if(!dictionary.ContainsKey(splitedLine[2]))
                {
                    dictionary.Add(splitedLine[2], student);
                }
                else
                {
                    dictionary[splitedLine[2]].Add(student);
                }

                line = reader.ReadLine();
            }

            foreach (var pair in dictionary)
            {
                Console.Write(pair.Key + " : ");

                var orderedList = pair.Value.OrderBy(v => v.LastName).ThenBy(v => v.FirstName).ToList();

                Console.WriteLine(string.Join(", ", orderedList.Select(s => s.FirstName + " " + s.LastName)));
            }
        }
开发者ID:MarinMarinov,项目名称:Data-structures-and-algorithms,代码行数:34,代码来源:Startup.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# OrderedPartCollection类代码示例发布时间:2022-05-24
下一篇:
C# OrderedDictionary类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap