public void AddArgumentNullException1() { // ReSharper disable once UnusedVariable var intervalDictionary = new IntervalDictionary <int, string> { { null, "5 - 10" } }; }
public void AddArgumentNullException2() { // ReSharper disable once UnusedVariable var intervalDictionary = new IntervalDictionary <int, string> { { new Interval <int>(5, 10), null } }; }
public void AddArgumentException2() { // ReSharper disable once UnusedVariable var intervalDictionary = new IntervalDictionary<int, string> { { new Interval<int>(5, 10), "5 - 10" }, { new Interval<int>(7, 9), "7 - 9" } }; }
public void AddArgumentException2() { // ReSharper disable once UnusedVariable var intervalDictionary = new IntervalDictionary <int, string> { { new Interval <int>(5, 10), "5 - 10" }, { new Interval <int>(7, 9), "7 - 9" } }; }
public void IndexerSetInterval() { var intervalDictionary = new IntervalDictionary <int, string>(); intervalDictionary[new Interval <int>(5, 10)] = "5 - 10"; intervalDictionary[new Interval <int>(15, 20)] = "15 - 20"; intervalDictionary[new Interval <int>(25, 25)] = "25 - 25"; Assert.AreEqual("5 - 10", intervalDictionary[new Interval <int>(5, 10)]); }
public void GetValueIntervalException() { 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" } }; Assert.AreEqual("5 - 15", intervalDictionary.GetValue(new Interval <int>(5, 15))); }
public void GetValueKeyException() { 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.GetValue(30); }
public void ContainsValueArgumentNullException() { 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.ContainsValue(null); }
public void IndexerGetInterval() { 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" } }; Assert.AreEqual("5 - 10", intervalDictionary[new Interval <int>(5, 10)]); }
public void IndexerSetKey() { var intervalDictionary = new IntervalDictionary <int, string>(); intervalDictionary[10] = "10 - 10"; intervalDictionary[15] = "15 - 15"; intervalDictionary[20] = "20 - 20"; Assert.AreEqual("10 - 10", intervalDictionary[10]); Assert.AreEqual("15 - 15", intervalDictionary[15]); Assert.AreEqual("20 - 20", intervalDictionary[20]); }
public void ContainsValue() { 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" } }; Assert.IsTrue(intervalDictionary.ContainsValue("5 - 10")); Assert.IsFalse(intervalDictionary.ContainsValue("5 - 15")); }
public void Clear() { 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" } }; Assert.AreEqual(3, intervalDictionary.Count); intervalDictionary.Clear(); Assert.AreEqual(0, intervalDictionary.Count); }
public void Clear() { 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" } }; Assert.AreEqual(3, intervalDictionary.Count); intervalDictionary.Clear(); Assert.AreEqual(0, intervalDictionary.Count); }
public void TryGetValueBound() { 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" } }; string result; Assert.IsFalse(intervalDictionary.TryGetValue(30, out result)); Assert.IsTrue(intervalDictionary.TryGetValue(25, out result)); Assert.AreEqual("25 - 25", result); }
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 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 Values() { 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" } }; var intervals = intervalDictionary.Values; Assert.IsTrue(intervals.Contains("5 - 10")); Assert.IsTrue(intervals.Contains("15 - 20")); Assert.IsTrue(intervals.Contains("25 - 25")); }
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 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 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 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 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 TryGetValueBoundArgumentNullException() { 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.GetValue(key: null); }
public void ContainsKeyArgumentNullException() { 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.ContainsKey(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 GetValueKey() { 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" } }; Assert.AreEqual("15 - 20", intervalDictionary.GetValue(15)); Assert.AreEqual("15 - 20", intervalDictionary.GetValue(17)); Assert.AreEqual("25 - 25", intervalDictionary.GetValue(25)); }
public void GetValueKeyException() { 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.GetValue(30); }
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 IndexerGetKey() { 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" } }; Assert.AreEqual("15 - 20", intervalDictionary[17]); Assert.AreEqual("25 - 25", intervalDictionary[25]); }
public void TryGetValueIntervalArgumentNullException() { 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.GetValue(null); }
public void TryGetValueInterval() { 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" } }; string result; Assert.IsFalse(intervalDictionary.TryGetValue(new Interval<int>(5, 15), out result)); Assert.IsTrue(intervalDictionary.TryGetValue(new Interval<int>(5, 10), out result)); Assert.AreEqual("5 - 10", result); }
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 IndexerSetKey() { var intervalDictionary = new IntervalDictionary<int, string>(); intervalDictionary[10] = "10 - 10"; intervalDictionary[15] = "15 - 15"; intervalDictionary[20] = "20 - 20"; Assert.AreEqual("10 - 10", intervalDictionary[10]); Assert.AreEqual("15 - 15", intervalDictionary[15]); Assert.AreEqual("20 - 20", intervalDictionary[20]); }
public void ReadOnly() { var intervalDictionary = new IntervalDictionary <int, string>(); Assert.AreEqual(false, intervalDictionary.IsReadOnly); }
public void ReadOnly() { var intervalDictionary = new IntervalDictionary<int, string>(); Assert.AreEqual(false, intervalDictionary.IsReadOnly); }
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 AddArgumentNullException2() { // ReSharper disable once UnusedVariable var intervalDictionary = new IntervalDictionary<int, string> { { new Interval<int>(5, 10), null } }; }
public void TryGetValueBoundArgumentNullException() { 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.GetValue(key: null); }
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 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 ContainsKeyArgumentNullException() { 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.ContainsKey(null); }
public void AddArgumentNullException1() { // ReSharper disable once UnusedVariable var intervalDictionary = new IntervalDictionary<int, string> { { null, "5 - 10" } }; }
public void IndexerSetInterval() { var intervalDictionary = new IntervalDictionary<int, string>(); intervalDictionary[new Interval<int>(5, 10)] = "5 - 10"; intervalDictionary[new Interval<int>(15, 20)] = "15 - 20"; intervalDictionary[new Interval<int>(25, 25)] = "25 - 25"; Assert.AreEqual("5 - 10", intervalDictionary[new Interval<int>(5, 10)]); }
public void ContainsInterval() { 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" } }; Assert.IsTrue(intervalDictionary.ContainsInterval(new Interval<int>(5, 10))); Assert.IsTrue(intervalDictionary.ContainsInterval(new Interval<int>(17, 18))); Assert.IsTrue(intervalDictionary.ContainsInterval(new Interval<int>(25, 25))); Assert.IsFalse(intervalDictionary.ContainsInterval(new Interval<int>(17, 25))); }
public void Values() { 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" } }; var intervals = intervalDictionary.Values; Assert.IsTrue(intervals.Contains("5 - 10")); Assert.IsTrue(intervals.Contains("15 - 20")); Assert.IsTrue(intervals.Contains("25 - 25")); }
public ProbabilityDictionary(Dictionary <K, double> probabilities) { accumulatedProbabilities = probabilities .SelectAggregate(new { Value = default(K) !, Acum = 0.0 }, (acum, kvp) => new { Value = kvp.Key, Acum = kvp.Value + acum.Acum })
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(); }