Ejemplo n.º 1
0
        public void CouldCalculateSMAWithWidthEQ()
        {
            Assert.Throws <NotImplementedException>(() =>
            {
                var count = 20;
                var sm    = new SortedMap <int, double>();
                sm.Add(0, 0);
                for (int i = 2; i <= count; i++)
                {
                    sm.Add(i, i);
                }
                sm.Remove(11);
                sm.Remove(12);
                var onlineOp = new SumAvgOnlineOp <int, double, SortedMapCursor <int, double> >();
                var smaOp    = new SpanOpWidth <int, double, double, SortedMapCursor <int, double>, SumAvgOnlineOp <int, double, SortedMapCursor <int, double> > >
                                   (2, Lookup.EQ, onlineOp);
                var smaSeries =
                    new SpanOpImpl <int,
                                    double,
                                    double,
                                    SpanOpWidth <int, double, double, SortedMapCursor <int, double>, SumAvgOnlineOp <int, double, SortedMapCursor <int, double> > >,
                                    SortedMapCursor <int, double>
                                    >(sm.GetEnumerator(), smaOp).Source;

                foreach (var keyValuePair in smaSeries)
                {
                    Trace.WriteLine($"{keyValuePair.Key} - {keyValuePair.Value}");
                }
            });
        }
Ejemplo n.º 2
0
        protected override ITransientMap DoWithout(object key)
        {
            var found = new Box(null);
            var t     = SortedMap.Remove(this._comp, this._tree, key, found);

            if (t is null)
            {
                return(this);
            }

            this._tree = t.Blacken();
            this._count--;
            return(this);
        }