예제 #1
0
        // AFTER

        public static Series <TKey, TValue, Range <TKey, TValue, TCursor> > After <TKey, TValue, TCursor>(
            this ContainerSeries <TKey, TValue, TCursor> series,
            TKey startKey, bool startInclusive = true)
            where TCursor : ISpecializedCursor <TKey, TValue, TCursor>
        {
            return(series.Range(startKey, Opt <TKey> .Missing, startInclusive, true));
        }
예제 #2
0
        // BEFORE

        public static Series <TKey, TValue, Range <TKey, TValue, TCursor> > Before <TKey, TValue, TCursor>(
            this ContainerSeries <TKey, TValue, TCursor> series,
            TKey endKey, bool endInclusive = true)
            where TCursor : ISpecializedCursor <TKey, TValue, TCursor>
        {
            return(series.Range(Opt <TKey> .Missing, endKey, true, endInclusive));
        }
예제 #3
0
        public static Series <TKey, TValue, Fill <TKey, TValue, TCursor> > Fill <TKey, TValue, TCursor>(
            this ContainerSeries <TKey, TValue, TCursor> series, TValue value)
            where TCursor : ICursor <TKey, TValue, TCursor>
        {
            var cursor = new Fill <TKey, TValue, TCursor>(series.GetContainerCursor(), value);

            return(cursor.Source);
        }
예제 #4
0
        public static Series <TKey, TResult, Map <TKey, TValue, TResult, TCursor> > Map <TKey, TValue, TResult, TCursor>(
            this ContainerSeries <TKey, TValue, TCursor> series, Func <TValue, TResult> selector)
            where TCursor : ISpecializedCursor <TKey, TValue, TCursor>
        {
            var cursor = new Map <TKey, TValue, TResult, TCursor>(series.GetContainerCursor(), selector);

            return(cursor.Source);
        }
예제 #5
0
        public static Series <TKey, (TValue, (TKey, TValue)), Lag <TKey, TValue, TCursor> > Lag <TKey, TValue, TCursor>(
            this ContainerSeries <TKey, TValue, TCursor> series, int lag = 1, int step = 1)
            where TCursor : ISpecializedCursor <TKey, TValue, TCursor>
        {
            var cursor = new Lag <TKey, TValue, TCursor>(series.GetContainerCursor(), lag + 1, step);

            return(cursor.Source);
        }
예제 #6
0
        public static Series <TKey, TValue, Filter <TKey, TValue, TCursor> > Filter <TKey, TValue, TCursor>(
            this ContainerSeries <TKey, TValue, TCursor> series, Func <TValue, bool> predicate)
            where TCursor : ISpecializedCursor <TKey, TValue, TCursor>
        {
            var cursor = new Filter <TKey, TValue, TCursor>(series.GetContainerCursor(), predicate);

            return(cursor.Source);
        }
예제 #7
0
        public static Series <TKey, Stat2 <TKey>, Stat2Cursor <TKey, TValue, TCursor> > Stat2 <TKey, TValue, TCursor>(
            this ContainerSeries <TKey, TValue, TCursor> series, TKey width, Lookup lookup = Lookup.GE)
            where TCursor : ICursor <TKey, TValue, TCursor>
        {
            var cursor = new Stat2Cursor <TKey, TValue, TCursor>(series.GetContainerCursor(), width, lookup);

            return(cursor.Source);
        }
예제 #8
0
        public static Series <TKey, Stat2 <TKey>, Stat2Cursor <TKey, TValue, TCursor> > Stat2 <TKey, TValue, TCursor>(
            this ContainerSeries <TKey, TValue, TCursor> series, int count, bool allowIncomplete = false)
            where TCursor : ICursor <TKey, TValue, TCursor>
        {
            var cursor = new Stat2Cursor <TKey, TValue, TCursor>(series.GetContainerCursor(), count, allowIncomplete);

            return(cursor.Source);
        }
예제 #9
0
 public static Series <TKey, TValue, Range <TKey, TValue, TCursor> > Range <TKey, TValue, TCursor>(
     this ContainerSeries <TKey, TValue, TCursor> series,
     TKey startKey, TKey endKey, bool startInclusive = true, bool endInclusive = true)
     where TCursor : ISpecializedCursor <TKey, TValue, TCursor>
 {
     // NB cast to Opt for overload resolution
     return(series.Range((Opt <TKey>)startKey, endKey, startInclusive, endInclusive));
 }
예제 #10
0
        public static Series <TKey, TValue, Repeat <TKey, TValue, TCursor> > Repeat <TKey, TValue, TCursor>(
            this ContainerSeries <TKey, TValue, TCursor> series)
            where TCursor : ISpecializedCursor <TKey, TValue, TCursor>
        {
            var cursor = new Repeat <TKey, TValue, TCursor>(series.GetContainerCursor());

            return(cursor.Source);
        }
예제 #11
0
        public static Series <TKey, (TKey, TValue), RepeatWithKey <TKey, TValue, TCursor> > RepeatWithKey <TKey, TValue, TCursor>(
            this ContainerSeries <TKey, TValue, TCursor> series)
            where TCursor : ICursor <TKey, TValue, TCursor>
        {
            var cursor = new RepeatWithKey <TKey, TValue, TCursor>(series.GetContainerCursor());

            return(cursor.Source);
        }
예제 #12
0
        // TODO see the trick with implicit conversion in ContainerSeries.* operator. Here it is also needed.

        // TODO! Series'3 extensions

        // TODO convenience methods on ValueTuple'3...'8 that accept a selector and flatten nested tuples

        // NB having methods that accept a selector achieves nothing in performance terms, only convenient signature

        #region ContainerSeries

        public static Series <TKey, (TLeft, TRight), Zip <TKey, TLeft, TRight, TCursorLeft, TCursorRight> > Zip <TKey, TLeft, TRight, TCursorLeft, TCursorRight>(
            this ContainerSeries <TKey, TLeft, TCursorLeft> series, ContainerSeries <TKey, TRight, TCursorRight> other)
            where TCursorLeft : ISpecializedCursor <TKey, TLeft, TCursorLeft>
            where TCursorRight : ISpecializedCursor <TKey, TRight, TCursorRight>
        {
            var zip = new Zip <TKey, TLeft, TRight, TCursorLeft, TCursorRight>(series.GetContainerCursor(), other.GetContainerCursor());

            return(zip.Source);
        }
예제 #13
0
        internal static Series <TKey, TValue, Range <TKey, TValue, TCursor> > Range <TKey, TValue, TCursor>(
            this ContainerSeries <TKey, TValue, TCursor> series,
            Opt <TKey> startKey, Opt <TKey> endKey, bool startInclusive = true, bool endInclusive = true)
            where TCursor : ISpecializedCursor <TKey, TValue, TCursor>
        {
            var cursor = new Range <TKey, TValue, TCursor>(
                series.GetContainerCursor(), startKey, endKey, startInclusive, endInclusive);

            return(cursor.Source);
        }
예제 #14
0
        public static Stat2 <TKey> Stat2 <TKey, TValue, TCursor>(this ContainerSeries <TKey, TValue, TCursor> series)
            where TCursor : ICursor <TKey, TValue, TCursor>
        {
            var stat = new Stat2 <TKey>();

            using (var cursor = series.GetContainerCursor())
            {
                var first = true;
                while (cursor.MoveNext())
                {
                    if (first)
                    {
                        stat._start = cursor.CurrentKey;
                        first       = false;
                    }
                    stat.AddValue(DoubleUtil.GetDouble(cursor.CurrentValue));
                }

                stat._end      = cursor.CurrentKey;
                stat._endValue = DoubleUtil.GetDouble(cursor.CurrentValue);
            }

            return(stat);
        }
예제 #15
0
this ContainerSeries <TKey, TValue, TCursor> series, Func <((TKey, TValue) current, (TKey, TValue) previous), TResult> selector, int lag = 1, int step = 1)
예제 #16
0
this ContainerSeries <TKey, TLeft, TCursorLeft> series, ContainerSeries <TKey, TRight, TCursorRight> other, Func <TKey, TLeft, TRight, TResult> selector)