public void Contains() { var intervalDictionary = new IntervalDictionary <int, string>(); var intervalValuePair1 = new IntervalValuePair <int, string>(new Interval <int>(5, 10), "5 - 10"); var intervalValuePair2 = new IntervalValuePair <int, string>(new Interval <int>(15, 20), "15 - 20"); var intervalValuePair3 = new IntervalValuePair <int, string>(new Interval <int>(25, 25), "25 - 25"); intervalDictionary.Add(intervalValuePair1); intervalDictionary.Add(intervalValuePair3); Assert.IsTrue(intervalDictionary.Contains(intervalValuePair1)); Assert.IsFalse(intervalDictionary.Contains(intervalValuePair2)); Assert.IsTrue(intervalDictionary.Contains(intervalValuePair3)); }
public void CopyToArgumentNullException() { var intervalDictionary = new IntervalDictionary <int, string>(); var intervalValuePair1 = new IntervalValuePair <int, string>(new Interval <int>(5, 10), "5 - 10"); var intervalValuePair2 = new IntervalValuePair <int, string>(new Interval <int>(15, 20), "15 - 20"); var intervalValuePair3 = new IntervalValuePair <int, string>(new Interval <int>(25, 25), "25 - 25"); intervalDictionary.Add(intervalValuePair1); intervalDictionary.Add(intervalValuePair2); intervalDictionary.Add(intervalValuePair3); // ReSharper disable once AssignNullToNotNullAttribute intervalDictionary.CopyTo(null, 0); }
public void Contains() { var intervalDictionary = new IntervalDictionary<int, string>(); var intervalValuePair1 = new IntervalValuePair<int, string>(new Interval<int>(5, 10), "5 - 10"); var intervalValuePair2 = new IntervalValuePair<int, string>(new Interval<int>(15, 20), "15 - 20"); var intervalValuePair3 = new IntervalValuePair<int, string>(new Interval<int>(25, 25), "25 - 25"); intervalDictionary.Add(intervalValuePair1); intervalDictionary.Add(intervalValuePair3); Assert.IsTrue(intervalDictionary.Contains(intervalValuePair1)); Assert.IsFalse(intervalDictionary.Contains(intervalValuePair2)); Assert.IsTrue(intervalDictionary.Contains(intervalValuePair3)); }
public void CopyToArgumentOutOfRangeException() { var intervalDictionary = new IntervalDictionary <int, string>(); var intervalValuePair1 = new IntervalValuePair <int, string>(new Interval <int>(5, 10), "5 - 10"); var intervalValuePair2 = new IntervalValuePair <int, string>(new Interval <int>(15, 20), "15 - 20"); var intervalValuePair3 = new IntervalValuePair <int, string>(new Interval <int>(25, 25), "25 - 25"); intervalDictionary.Add(intervalValuePair1); intervalDictionary.Add(intervalValuePair2); intervalDictionary.Add(intervalValuePair3); var a = new IntervalValuePair <int, string> [5]; intervalDictionary.CopyTo(a, -1); }
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 IEnumerableGetEnumerator() { var intervalDictionary = new IntervalDictionary <int, string>(); var intervalValuePair1 = new IntervalValuePair <int, string>(new Interval <int>(5, 10), "5 - 10"); var intervalValuePair2 = new IntervalValuePair <int, string>(new Interval <int>(15, 20), "15 - 20"); var intervalValuePair3 = new IntervalValuePair <int, string>(new Interval <int>(25, 25), "25 - 25"); intervalDictionary.Add(intervalValuePair1); intervalDictionary.Add(intervalValuePair2); intervalDictionary.Add(intervalValuePair3); foreach (var pair in (IEnumerable)intervalDictionary) { Assert.IsTrue( pair.Equals(intervalValuePair1) || pair.Equals(intervalValuePair2) || pair.Equals(intervalValuePair3)); } }
public void CopyTo() { var intervalDictionary = new IntervalDictionary <int, string>(); var intervalValuePair1 = new IntervalValuePair <int, string>(new Interval <int>(5, 10), "5 - 10"); var intervalValuePair2 = new IntervalValuePair <int, string>(new Interval <int>(15, 20), "15 - 20"); var intervalValuePair3 = new IntervalValuePair <int, string>(new Interval <int>(25, 25), "25 - 25"); intervalDictionary.Add(intervalValuePair1); intervalDictionary.Add(intervalValuePair2); intervalDictionary.Add(intervalValuePair3); var a = new IntervalValuePair <int, string> [5]; intervalDictionary.CopyTo(a, 0); Assert.AreEqual(intervalValuePair1, a[0]); Assert.AreEqual(intervalValuePair2, a[1]); Assert.AreEqual(intervalValuePair3, a[2]); }
public void IEnumerableGetEnumerator() { var intervalDictionary = new IntervalDictionary<int, string>(); var intervalValuePair1 = new IntervalValuePair<int, string>(new Interval<int>(5, 10), "5 - 10"); var intervalValuePair2 = new IntervalValuePair<int, string>(new Interval<int>(15, 20), "15 - 20"); var intervalValuePair3 = new IntervalValuePair<int, string>(new Interval<int>(25, 25), "25 - 25"); intervalDictionary.Add(intervalValuePair1); intervalDictionary.Add(intervalValuePair2); intervalDictionary.Add(intervalValuePair3); foreach (var pair in (IEnumerable)intervalDictionary) { Assert.IsTrue( pair.Equals(intervalValuePair1) || pair.Equals(intervalValuePair2) || pair.Equals(intervalValuePair3)); } }
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 CopyToArgumentOutOfRangeException() { var intervalDictionary = new IntervalDictionary<int, string>(); var intervalValuePair1 = new IntervalValuePair<int, string>(new Interval<int>(5, 10), "5 - 10"); var intervalValuePair2 = new IntervalValuePair<int, string>(new Interval<int>(15, 20), "15 - 20"); var intervalValuePair3 = new IntervalValuePair<int, string>(new Interval<int>(25, 25), "25 - 25"); intervalDictionary.Add(intervalValuePair1); intervalDictionary.Add(intervalValuePair2); intervalDictionary.Add(intervalValuePair3); var a = new IntervalValuePair<int, string>[5]; intervalDictionary.CopyTo(a, -1); }
public void CopyToArgumentNullException() { var intervalDictionary = new IntervalDictionary<int, string>(); var intervalValuePair1 = new IntervalValuePair<int, string>(new Interval<int>(5, 10), "5 - 10"); var intervalValuePair2 = new IntervalValuePair<int, string>(new Interval<int>(15, 20), "15 - 20"); var intervalValuePair3 = new IntervalValuePair<int, string>(new Interval<int>(25, 25), "25 - 25"); intervalDictionary.Add(intervalValuePair1); intervalDictionary.Add(intervalValuePair2); intervalDictionary.Add(intervalValuePair3); // ReSharper disable once AssignNullToNotNullAttribute intervalDictionary.CopyTo(null, 0); }
public void CopyTo() { var intervalDictionary = new IntervalDictionary<int, string>(); var intervalValuePair1 = new IntervalValuePair<int, string>(new Interval<int>(5, 10), "5 - 10"); var intervalValuePair2 = new IntervalValuePair<int, string>(new Interval<int>(15, 20), "15 - 20"); var intervalValuePair3 = new IntervalValuePair<int, string>(new Interval<int>(25, 25), "25 - 25"); intervalDictionary.Add(intervalValuePair1); intervalDictionary.Add(intervalValuePair2); intervalDictionary.Add(intervalValuePair3); var a = new IntervalValuePair<int, string>[5]; intervalDictionary.CopyTo(a, 0); Assert.AreEqual(intervalValuePair1, a[0]); Assert.AreEqual(intervalValuePair2, a[1]); Assert.AreEqual(intervalValuePair3, a[2]); }
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(); }