public void Send(Weighted <R> record) { Logging.Info("[BMRS {1}] Sending record: {0}", record, this.name); long value = 0; bool exists = this.lastEpochAccumulation.TryGetValue(record.record, out value); if (exists && value + record.weight == 0) { this.lastEpochAccumulation.Remove(record.record); } else { this.lastEpochAccumulation[record.record] = value + record.weight; } }
private void DeferredSend(Weighted <R> record) { if (record.weight < 0) { for (int i = 0; i < -record.weight; ++i) { this.collection.Remove(record.record); } } else { for (int i = 0; i < record.weight; ++i) { this.collection.Add(record.record); } } }
/// <summary> /// Adds a single record with an integer weight and signals that the <see cref="InputCollection{TRecord}"/> is complete. /// </summary> /// <param name="input">The input.</param> /// <param name="value">The record.</param> /// <typeparam name="TRecord">The type of the record.</typeparam> public static void OnCompleted <TRecord>(this InputCollection <TRecord> input, Weighted <TRecord> value) where TRecord : IEquatable <TRecord> { input.OnCompleted(new Weighted <TRecord>[] { value }); }
public void Send(Weighted <R> record) { Console.Error.WriteLine("Got!: {0}", record); this.buffer.Add(record); }
public void Send(Weighted <R> record) { Debug.Assert(record.weight == -1 || record.weight == 1); this.buffer.Add(record); }
/// <summary> /// Returns <c>true</c> if and only if this and the <paramref name="other"/> object have equal records and weights. /// </summary> /// <param name="other">The other object.</param> /// <returns><c>true</c> if and only if this and the <paramref name="other"/> object have equal records and weights.</returns> public bool Equals(Weighted <TRecord> other) { return(this.weight == other.weight && this.record.Equals(other.record)); }