public override void Flush(bool force = false) { if (force || IsChanged) { // Write the buffered data to the out stream. FOutStream.AssignFrom(this); FOutStream.Flush(force); } base.Flush(force); }
public override void Flush() { if (IsChanged) { // Write the buffered data to the out stream. FOutStream.AssignFrom(this); FOutStream.Flush(); } base.Flush(); }
public static void AssignFrom<T>(this IOutStream<T> outStream, IInStream<T> inStream) { var buffer = MemoryPool<T>.GetArray(); try { outStream.AssignFrom(inStream, buffer); } finally { MemoryPool<T>.PutArray(buffer); } }
#pragma warning restore #endregion fields & pins //called when data for any output pin is requested public void Evaluate(int SpreadMax) { FInput.Sync(); FVec.Sync(); FBin.Sync(); if (FInput.IsChanged || FVec.IsChanged || FBin.IsChanged) { if (FInput.Length > 0 && FVec.Length > 0 && FBin.Length > 0) { int vecSize = Math.Max(1, FVec.GetReader().Read()); spread.Sync(FInput, vecSize, FBin); FLast.Length = spread.NonEmptyBinCount * vecSize; if (FLast.Length == spread.ItemCount || spread.ItemCount == 0) { FRemainder.Length = 0; if (spread.ItemCount != 0) { FLast.AssignFrom(FInput); } else { FLast.Length = 0; } } else { FRemainder.Length = spread.ItemCount - FLast.Length; using (var rWriter = FRemainder.GetWriter()) using (var lWriter = FLast.GetWriter()) { for (int b = 0; b < spread.Count; b++) { if (spread[b].Length > 0) { int rLength = spread[b].Length - vecSize; rWriter.Write(spread[b], 0, rLength); lWriter.Write(spread[b], rLength, vecSize); } } } } } else { FRemainder.Length = FLast.Length = 0; } } }
#pragma warning restore #endregion fields & pins //called when data for any output pin is requested public void Evaluate(int SpreadMax) { FInput.Sync(); FVec.Sync(); FBin.Sync(); if (FInput.IsChanged || FVec.IsChanged || FBin.IsChanged) { if (FInput.Length > 0 && FVec.Length > 0 && FBin.Length > 0) { int vecSize = Math.Max(1, FVec.GetReader().Read()); VecBinSpread <double> spread = new VecBinSpread <double>(FInput, vecSize, FBin); FFirst.Length = spread.Count * vecSize; if (FFirst.Length == spread.ItemCount || spread.ItemCount == 0) { FRemainder.Length = 0; if (spread.ItemCount != 0) { FFirst.AssignFrom(FInput); } else { FFirst.Length = 0; } } else { FRemainder.Length = spread.ItemCount - FFirst.Length; using (var fWriter = FFirst.GetWriter()) using (var rWriter = FRemainder.GetWriter()) { for (int b = 0; b < spread.Count; b++) { fWriter.Write(spread.GetBinRow(b, 0).ToArray(), 0, vecSize); rWriter.Write(spread[b], vecSize, spread[b].Length - vecSize); } } } } else { FFirst.Length = FRemainder.Length = 0; } } }
#pragma warning restore #endregion fields & pins //called when data for any output pin is requested public void Evaluate(int SpreadMax) { FInput.Sync(); FBin.Sync(); if (FInput.IsChanged || FBin.IsChanged) { spread.Sync(FInput, 1, FBin); FLast.Length = spread.Count; if (FLast.Length == spread.ItemCount || spread.ItemCount == 0) { FRemainder.Length = 0; if (spread.ItemCount != 0) { FLast.AssignFrom(FInput); } else { FLast.Length = 0; } } else { FRemainder.Length = spread.ItemCount - FLast.Length; using (var rWriter = FRemainder.GetWriter()) using (var lWriter = FLast.GetWriter()) { for (int b = 0; b < spread.Count; b++) { int rLength = spread[b].Length - 1; rWriter.Write(spread[b], 0, rLength); lWriter.Write(spread[b][rLength]); } } } } }
public static void AssignFrom <T>(this IOutStream <T> outStream, IInStream <T> inStream) { if (inStream.Length != 1) { var buffer = MemoryPool <T> .GetArray(); try { outStream.AssignFrom(inStream, buffer); } finally { MemoryPool <T> .PutArray(buffer); } } else { outStream.Length = 1; using (var reader = inStream.GetReader()) using (var writer = outStream.GetWriter()) writer.Write(reader.Read()); } }
#pragma warning restore #endregion fields & pins //called when data for any output pin is requested public void Evaluate(int SpreadMax) { FInput.Sync(); FBin.Sync(); if (FInput.IsChanged || FBin.IsChanged) { VecBinSpread <T> spread = new VecBinSpread <T>(FInput, 1, FBin); FFirst.Length = spread.Count; if (FFirst.Length == spread.ItemCount || spread.ItemCount == 0) { FRemainder.Length = 0; if (spread.ItemCount != 0) { FFirst.AssignFrom(FInput); } else { FFirst.Length = 0; }; } else { FRemainder.Length = spread.ItemCount - FFirst.Length; using (var fWriter = FFirst.GetWriter()) using (var rWriter = FRemainder.GetWriter()) { for (int b = 0; b < spread.Count; b++) { fWriter.Write(spread[b][0]); rWriter.Write(spread[b], 1, spread[b].Length - 1); } } } } }
void AssignStream <T>(IInStream <T> source, IOutStream <T> dest) { dest.AssignFrom(source); }