本文整理汇总了C#中IObservable.Scan方法的典型用法代码示例。如果您正苦于以下问题:C# IObservable.Scan方法的具体用法?C# IObservable.Scan怎么用?C# IObservable.Scan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObservable
的用法示例。
在下文中一共展示了IObservable.Scan方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FileSegmenter
public FileSegmenter(IObservable<FileNotification> notifications,
int initialTail= 100000,
int segmentSize=25000000)
{
if (notifications == null) throw new ArgumentNullException(nameof(notifications));
_initialTail = initialTail;
_segmentSize = segmentSize;
//TODO: Re-segment as file grows + account for rollover
Segments = notifications
//.notifications()
.Scan((FileSegmentCollection) null, (previous, current) =>
{
if (previous == null || previous.FileLength == 0)
{
_info =(FileInfo) current;
var segments = LoadSegments().ToArray();
return new FileSegmentCollection(_info, segments, current.Size);
}
var newLength = _info.Length;
if (newLength < previous.FileLength)
{
var sizeDiff = newLength - previous.FileLength;
var segments = LoadSegments().ToArray();
return new FileSegmentCollection(_info, segments, sizeDiff);
}
return new FileSegmentCollection(newLength, previous);
}).Replay(1).RefCount();
}
示例2: Filter
public static IObservable<float> Filter(IObservable<float> src, int bufferSize)
{
return src.Scan(new Queue<float>(),
(queue, f) =>
{
queue.Enqueue(f);
if (queue.Count > bufferSize)
queue.Dequeue();
return queue;
}).Select(q => q.Average());
}
示例3: computeTeamBallPossessionFullGame
//this function computes the TeamBall Possession data for the entire game
public static IObservable<TeamBallPossession> computeTeamBallPossessionFullGame(IObservable<PlayerBallPossession> src)
{
List<PlayerBallPossession> expList = new List<PlayerBallPossession>();
return src
.Scan(new Aggregate { currTeam = "", pTimeA = 0.0, pTimeB = 0.0, ts = 0 }, (seed, val) =>
{
seed = aggregatorFunction(seed, val, expList, 0);
return seed;
})
.Select(b => getTeamPossessionData(b));
}
示例4: AddAggregator
public static void AddAggregator(IDataPublisher publisher,
IAggregator<double, double> agg,
Action<double, string> act, int symbolId)
{
eventAsObservable = from update in Observable.FromEvent<OnFeedReceived, Feed>(
mktH => publisher.FeedArrived += mktH,
mktH => publisher.FeedArrived -= mktH
).Where((feed) => feed.SymbolId == symbolId)
select update.LTP;
//aggregates and yields results.
subs = eventAsObservable
.Scan<double, double>(0,
(acc, currentValue) =>
{
return agg.Aggregate(currentValue);
}).Subscribe((state) => act(state, Constants.REDIS_MVA_ROOM_PREFIX + symbolId));
}
示例5: PathLength
public IObservable<double> PathLength(IObservable<PointF> centerObservable)
{
return
centerObservable.Scan(new Tuple<double, PointF>(0, PointF.Empty), CalculateLength)
.Select(tuple => tuple.Item1);
}
示例6: Analize
public IObservable<Indicators> Analize(IObservable<PointF> centerObservable)
{
return centerObservable.Scan(new State(), ProcessNextPoint)
.Select(state => state.Indicators);
}
示例7: AddThreshold
private static IObservable<Vector3> AddThreshold(IObservable<Vector3> stream, float threshold)
{
return stream
.Scan((prev, current) =>
{
return Vector3.Distance(prev, current) < threshold ? prev : current;
})
.DistinctUntilChanged();
}