public ValueVector AddValue(long time, object value, VectorConflictStrategy strategy) { if (Vector.Count == 0 || time > Time) { return(new ValueVector(time, List(value))); } if (time < Time) { // A value from the past has arrived, we're going to drop it because // we've already moved on. return(this); } if (Vector.Exists(x => x.Equals(value))) { // There's already an entry at the same time with the // same value return(this); } else { // Conflict! switch (strategy) { case VectorConflictStrategy.First: return(this); case VectorConflictStrategy.Last: return(new ValueVector(time, List(value))); case VectorConflictStrategy.Branch: return(new ValueVector(Time, Vector.Add(value))); default: throw new ArgumentException("VectorConflictStrategy not supported: " + strategy); } } }
private void button1_Click(object sender, EventArgs e) { if (YZ()) { if (string.IsNullOrEmpty(Xh)) { Lst.Add(new Student() { ID = textBox1.Text.Trim(), Name = textBox2.Text.Trim(), Age = int.Parse(textBox3.Text.Trim()), GenderText = textBox4.Text.Trim() }); } else { Student st1 = Lst.FirstOrDefault(c => c.ID == textBox1.Text); st1.Name = textBox2.Text.Trim(); st1.Age = int.Parse(textBox3.Text.Trim()); st1.GenderText = textBox4.Text.Trim(); } if (Handler != null) { Handler(); } } Close(); }
public static IEnumerable <Items> Do( IEnumerable <T> items, Func <T, TimeRange> getTimeRange, DateTime dtMin, DateTime dtMax) { var lst = new Lst(); var lstMaxEndTime = dtMin; foreach (var item in items) { var tr = getTimeRange(item); if (tr.endTime == DateTime.MinValue) { continue; } if (lstMaxEndTime <= tr.time && lst.Count > 0) { if (lst.Count == 1) { yield return(lst[0].ToItems(dtMin, tr.time)); } else { foreach (var tuple in EnumerateLst(lst, dtMin, tr.time)) { yield return(tuple); } } lst.Clear(); dtMin = tr.time; } if (lstMaxEndTime < tr.endTime) { lstMaxEndTime = tr.endTime; } lst.Add(new Item() { timeRng = tr, item = item }); } if (lst.Count > 0) { if (lst.Count == 1) { yield return(lst[0].ToItems(dtMin, dtMax)); } else { foreach (var tuple in EnumerateLst(lst, dtMin, dtMax)) { yield return(tuple); } } } }
public Node Lst() { var result = new Lst(); Expect(TokenCategory.LEFT_BRACES); if (simpleLiterals.Contains(CurrentToken)) { result.Add(SimpleLiteral()); while (CurrentToken == TokenCategory.COMA) { Expect(TokenCategory.COMA); result.Add(SimpleLiteral()); } } Expect(TokenCategory.RIGHT_BRACES); return(result); }
private static void WriteDelegates(IMapItem <string, Namespace> ns, string nspath, Lst <Tuple <string, string> > trail) { ns.Value.Delegates.Filter(t => t.Visibility == Vis.Public).Select(type => { var tpath = Path.Combine(nspath, $"{type.UniqueName}.htm"); File.WriteAllText( tpath, Body.Build( trail.Add(Tuple(type.Name.ToString(), $"{type.UniqueName}.htm")), DelegatePage.page )(Tuple(ns.Key, type)).AsString() ); return(type); }).AsParallel().ToList(); }