public void add_two_counts() { var count1 = new Counts { Rights = 2, Wrongs = 3, Exceptions = 4, SyntaxErrors = 7 }; var count2 = new Counts { Rights = 7, Wrongs = 4, Exceptions = 10, SyntaxErrors = 14 }; count1.Add(count2); count1.Rights.ShouldBe(9); count1.Wrongs.ShouldBe(7); count1.Exceptions.ShouldBe(14); count1.SyntaxErrors.ShouldBe(21); count2.Rights.ShouldBe(7); count2.Wrongs.ShouldBe(4); count2.Exceptions.ShouldBe(10); count2.SyntaxErrors.ShouldBe(14); }
public void ReloadSeries() { var views = items.Where(p => p.IsFinishedWithDate).ToList(); Series.Clear(); Counts.Clear(); foreach (var t in MovieViewModel.TypesDict) { int c = 0; var points = new List <DataModel>(); for (var dt = 2012; dt <= DateTime.Today.Year; dt = dt + 1) { var count = views.Count(p => p.FinishDate.Value.Year == dt && p.Type == t.Key); points.Add( new DataModel() { Year = dt, Count = count }); c = c + count; } var a = new StackedColumnSeries() { Values = new ChartValues <DataModel>(points), Title = t.Value, Fill = ConvertFuncs.TypeToBrushFunc(t.Key) }; Series.Add(a); Counts.Add(new CountClass(c, t.Key, t.Value)); } Totals = Counts.Sum(p => p.Count); Reloaded?.Invoke(null, EventArgs.Empty); }
public void ReloadSeries() { var views = items.Where(p => p.States.IsStateDoneWithDate(StateEnum.Finished)).ToList(); Series.Clear(); Counts.Clear(); foreach (var t in MovieViewModel.TypesDict) { int c = 0; var points = new List <DateTimePoint>(); for (var dt = FirstDay; dt <= LastDay; dt = dt.AddDays(1)) { var count = views.Count(p => p.FinishDate == dt && p.Type == t.Key); points.Add( new DateTimePoint() { DateTime = dt, Value = count }); c = c + count; } var a = new StackedColumnSeries() { Values = new ChartValues <DateTimePoint>(points), Title = t.Value, Fill = ConvertFuncs.TypeToBrushFunc(t.Key) }; Series.Add(a); Counts.Add(new CountClass(c, t.Key, t.Value)); } Totals = Counts.Sum(p => p.Count); Reloaded?.Invoke(null, EventArgs.Empty); }
public void SetKey(string Key, string Value) { if (Capacity <= 0) { return; } // If key does exist, we're returning from here if (Vals.ContainsKey(Key)) { Vals.Add(Key, Value); GetKey(Key); return; } if (Vals.Count >= Capacity) { IEnumerator <string> enumerator = Lists[Minimum].GetEnumerator(); if (enumerator.MoveNext()) { string evit = enumerator.Current; Lists[Minimum].Remove(evit); Vals.Remove(evit); Counts.Remove(evit); } else { throw new ArgumentOutOfRangeException("Invalid access at SetKey!"); } } Console.WriteLine("Hereererre"); // If the key is new, insert the value and current // min should be 1 of course if (!Vals.ContainsKey(Key)) { Vals.Add(Key, Value); } if (!Counts.ContainsKey(Key)) { Counts.Add(Key, 1); } Minimum = 1; if (!Lists.ContainsKey(Minimum)) { Lists.Add(Minimum, new LinkedHashSet <string>()); } else { Lists[Minimum].Add(Key); } }
public void Add(string key, ulong value = 1) { ulong current; if (Counts.TryGetValue(key, out current)) { Counts[key] = current + value; } else { Counts.Add(key, value); } }
public SimpleMoviesList(List <MovieViewModel> lst) { InitializeComponent(); Items = lst.OrderBy(p => p.States.Items[StateEnum.Finished].Date).ToList(); foreach (var t in MovieViewModel.TypesDict) { Counts.Add( new CountClass(Items.Count(p => p.Type == t.Key), t.Key, t.Value) ); } Totals = Counts.Sum(p => p.Count); // define the dialog buttons this.Buttons = new Button[] { this.OkButton }; DataContext = this; }
public string GetKey(string key) { if (!Vals.ContainsKey(key)) { return(""); } // Get the count from counts map Int64 Count = Counts[key]; // Increase the counter if (!Counts.ContainsKey(key)) { Counts.Add(key, Count + 1); } // Remove the element from the counter to LinkedHashSet Lists[Count].Remove(key); // When the current min does not have any data, next // one would be the min if (Count == Minimum && Lists[Count].Count == 0) { Minimum += Minimum + 1; } if (!Lists.ContainsKey(Count + 1)) { Lists.Add(Count + 1, new LinkedHashSet <string>()); } Lists[Count].Add(key); return(Vals[key]); }