当前位置: 首页>>代码示例>>C#>>正文


C# IObservable.Scan方法代码示例

本文整理汇总了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();
        }
开发者ID:RomanBlyshchyk,项目名称:TailBlazer,代码行数:32,代码来源:FileSegmenter.cs

示例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());
 }
开发者ID:Shinbuev,项目名称:Orthopedy,代码行数:11,代码来源:CurrentAvfFilter.cs

示例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));
        }
开发者ID:mindis,项目名称:rticonnextdds-reactive,代码行数:13,代码来源:TeamBallPossessionQuery.cs

示例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));
        }
开发者ID:togglebrain,项目名称:stock-analytics,代码行数:18,代码来源:RXProcessing.cs

示例5: PathLength

 public IObservable<double> PathLength(IObservable<PointF> centerObservable)
 {
     return
         centerObservable.Scan(new Tuple<double, PointF>(0, PointF.Empty), CalculateLength)
             .Select(tuple => tuple.Item1);
 }
开发者ID:Shinbuev,项目名称:Orthopedy,代码行数:6,代码来源:PlatformDiagnostic.cs

示例6: Analize

 public IObservable<Indicators> Analize(IObservable<PointF> centerObservable)
 {
     return centerObservable.Scan(new State(), ProcessNextPoint)
         .Select(state => state.Indicators);
 }
开发者ID:Shinbuev,项目名称:Orthopedy,代码行数:5,代码来源:PlatformDiagnostic.cs

示例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();
 }
开发者ID:Lisy09Personal,项目名称:UnityChanRoadRx,代码行数:9,代码来源:Drag.cs


注:本文中的IObservable.Scan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。