public void RemoveIntervalArgumentNullException()
        {
            var intervalDictionary = new IntervalDictionary <int, string>
            {
                { new Interval <int>(5, 10), "5 - 10" },
                { new Interval <int>(15, 20), "15 - 20" },
                { new Interval <int>(25, 25), "25 - 25" }
            };

            intervalDictionary.Remove(null);
        }
        public void Count()
        {
            var intervalDictionary = new IntervalDictionary <int, string>();

            Assert.AreEqual(0, intervalDictionary.Count);

            intervalDictionary.Add(new Interval <int>(5, 10), "5 - 10");
            intervalDictionary.Add(new Interval <int>(15, 20), "15 - 20");
            intervalDictionary.Add(new Interval <int>(25, 25), "25 - 25");

            Assert.AreEqual(3, intervalDictionary.Count);

            intervalDictionary.Remove(new Interval <int>(15, 20));

            Assert.AreEqual(2, intervalDictionary.Count);
        }
        public void RemoveKeyArgumentNullException()
        {
            var intervalDictionary = new IntervalDictionary <string, string>
            {
                {
                    new Interval <string>("a", "c"),
                    "a - c"
                },
                {
                    new Interval <string>("h", "j"),
                    "h - j"
                },
                {
                    new Interval <string>("x", "z"),
                    "x - z"
                }
            };

            intervalDictionary.Remove(key: null);
        }
        public void RemoveKeyArgumentNullException()
        {
            var intervalDictionary = new IntervalDictionary<string, string>
                                         {
                                             {
                                                 new Interval<string>("a", "c"),
                                                 "a - c"
                                             },
                                             {
                                                 new Interval<string>("h", "j"),
                                                 "h - j"
                                             },
                                             {
                                                 new Interval<string>("x", "z"),
                                                 "x - z"
                                             }
                                         };

            intervalDictionary.Remove(key: null);
        }
        public void RemoveIntervalArgumentNullException()
        {
            var intervalDictionary = new IntervalDictionary<int, string>
                                         {
                                             { new Interval<int>(5, 10), "5 - 10" },
                                             { new Interval<int>(15, 20), "15 - 20" },
                                             { new Interval<int>(25, 25), "25 - 25" }
                                         };

            intervalDictionary.Remove(null);
        }
        public void Count()
        {
            var intervalDictionary = new IntervalDictionary<int, string>();

            Assert.AreEqual(0, intervalDictionary.Count);

            intervalDictionary.Add(new Interval<int>(5, 10), "5 - 10");
            intervalDictionary.Add(new Interval<int>(15, 20), "15 - 20");
            intervalDictionary.Add(new Interval<int>(25, 25), "25 - 25");

            Assert.AreEqual(3, intervalDictionary.Count);

            intervalDictionary.Remove(new Interval<int>(15, 20));

            Assert.AreEqual(2, intervalDictionary.Count);
        }
Exemple #7
0
        static void Main(string[] args)
        {
            IntervalDictionary<int, string> dict = new IntervalDictionary<int, string>();

            dict.Add(1, 1, "one");
            dict.Add(2, 2, "two");
            dict.Add(3, 3, "three");
            dict.Add(4, 4, "four");
            dict.Add(5, 5, "five");
            dict.Add(6, 6, "six");
            dict.Add(7, 7, "seven");
            dict.Add(8, 8, "eight");
            dict.Add(9, 9, "nine");
            dict.Add(10,10, "ten");
            dict.Add(11,11, "eleven");
            dict.Add(12, 12, "zwulf");
            dict.Add(13, 13, "thirteen");
            dict.Add(14, 14, "fourteen");
            dict.Add(15, 15, "fifteen");

            dict.Remove(12);
            dict.Remove(1);

            //dict.Remove(4);

            dict.Remove(2);

            return;

            var test = new IntervalDictionary<int, string>();
            var dic = new Dictionary<int, string>();

            var c = 1e6; //Math.Pow(2,16)-1;
            var n = 1;

            DateTime start = DateTime.Now;

            for(int i = 0; i < c; i += n)
            {
                //test.Add(i, i + n - 1, i.ToString());
                dic.Add(i, i.ToString());
            }

            DateTime end = DateTime.Now;

            int count = test.Count;

            var t = end.Subtract(start).TotalMilliseconds;

            double elapsed = end.Subtract(start).TotalMilliseconds * n / c;

            IntervalDictionary<int,string> months = new IntervalDictionary<int, string>();

            months.Add(1, 31, "January");
            months.Add(32, 59, "February");
            months.Add(60, 90, "March");
            months.Add(91, 120, "April");
            months.Add(121, 151, "May");
            months.Add(152, 181, "June");
            months.Add(182, 212, "July");
            months.Add(213, 243, "August");
            months.Add(244, 273, "September");
            months.Add(274, 304, "October");
            months.Add(305, 334, "November");
            months.Add(335, 365, "December");

            string month = months[264];

            var x = months.First();
        }