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


C# SortedMap.Repeat方法代码示例

本文整理汇总了C#中SortedMap.Repeat方法的典型用法代码示例。如果您正苦于以下问题:C# SortedMap.Repeat方法的具体用法?C# SortedMap.Repeat怎么用?C# SortedMap.Repeat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SortedMap的用法示例。


在下文中一共展示了SortedMap.Repeat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CouldRepeatSeries

        public void CouldRepeatSeries() {
            var sm = new SortedMap<DateTime, double>();
            var sm2 = new SortedMap<DateTime, double>();

            var count = 1000000;

            for (int i = 0; i < count; i++) {
                sm.Add(DateTime.UtcNow.Date.AddSeconds(i * 2), i);
            }

            for (int i = 0; i < count; i++) {
                sm2.Add(DateTime.UtcNow.Date.AddSeconds(i * 2 + 1), i);
            }

            var expected = 0.0;
            for (int i = 0; i < count; i++) {
                expected += i * 2; ;
            }

            var sw = new Stopwatch();
            sw.Start();
            var sum = (sm.Repeat() + sm2).Values.Sum();
            sw.Stop();
            Assert.AreEqual(expected, sum);
            Console.WriteLine("Repeat + zip, elapsed: {0}, ops: {1}", sw.ElapsedMilliseconds, (int)((double)count / (sw.ElapsedMilliseconds / 1000.0)));

        }
开发者ID:b-e-n-j,项目名称:Spreads,代码行数:27,代码来源:MissingValuesCursorsTests.cs

示例2: ZipNFromLogoAndReadmeRepeatCouldMoveCursorCorrectly

        public void ZipNFromLogoAndReadmeRepeatCouldMoveCursorCorrectly() {
            var upper = new SortedMap<int, int> { { 2, 2 }, { 4, 4 } };
            var lower = new SortedMap<int, int> { { 1, 10 }, { 3, 30 }, { 5, 50 } };
            var sum = (upper.Repeat() + lower);
            var cursor = sum.GetCursor();

            Assert.AreEqual(32, sum[3]);
            Assert.AreEqual(54, sum[5]);

            Assert.IsFalse(cursor.MoveAt(1, Lookup.EQ));
            Assert.IsTrue(cursor.MoveAt(1, Lookup.GE));
            Assert.AreEqual(3, cursor.CurrentKey);
            Assert.AreEqual(32, cursor.CurrentValue);

            // move forward

            Assert.IsTrue(cursor.MoveNext());
            Assert.AreEqual(5, cursor.CurrentKey);
            Assert.AreEqual(54, cursor.CurrentValue);

            // finished
            Assert.IsFalse(cursor.MoveNext());

            //// move back

            Assert.IsTrue(cursor.MovePrevious());
            Assert.AreEqual(3, cursor.CurrentKey);
            Assert.AreEqual(32, cursor.CurrentValue);

            // async moves
            Assert.IsTrue(cursor.MoveNext(CancellationToken.None).Result);
            Assert.AreEqual(5, cursor.CurrentKey);
            Assert.AreEqual(54, cursor.CurrentValue);

            var moved = false;
            var t = Task.Run(async () => {
                moved = await cursor.MoveNext(CancellationToken.None);
            });

            // add new value
            lower.Add(6, 60);
            t.Wait();
            Assert.IsTrue(moved);
            Assert.AreEqual(6, cursor.CurrentKey);
            Assert.AreEqual(4 + 60, cursor.CurrentValue);

            // when all sources are marked as immutable/complete, MNA must return false
            var t2 = Task.Run(async () => {
                moved = await cursor.MoveNext(CancellationToken.None);
            });
            upper.Complete();
            lower.Complete();
            t2.Wait();
            Assert.IsFalse(moved);

        }
开发者ID:Applied-Duality,项目名称:Spreads,代码行数:56,代码来源:ReadmeTests.cs

示例3: CouldMoveAtPositionOfThreeDifferentSeriesAllContinuous

        public void CouldMoveAtPositionOfThreeDifferentSeriesAllContinuous() {

            var sm1 = new SortedMap<int, int>(new Dictionary<int, int>()
                {
                    { 1, 1},
                    //{ 2, 2}, // Fill(100)
                    { 3, 3},
                    //{ 5, 5}, // Fill(100)
                    { 7, 7}
                });
            var sm2 = new SortedMap<int, int>(new Dictionary<int, int>()
                {
                    { 1, 2},
                    { 2, 4},
                    { 3, 6},
                    { 5, 10},
                    { 7, 14}

                });
            var sm3 = new SortedMap<int, int>(new Dictionary<int, int>()
                {
                    { 1, 3},
                    { 2, 6},
                    { 3, 9},
                    { 5, 15},
                    { 7, 21}
                });

            var series = new[] { sm1.Fill(100), sm2.Repeat(), sm3.Repeat() };
            var sum = series.Zip((k, varr) => k * varr.Sum());

            var zipNCursor = sum.GetCursor();
            var movedAtEQ = zipNCursor.MoveAt(3, Lookup.EQ);
            Assert.IsTrue(movedAtEQ);
            Assert.AreEqual((3 + 6 + 9) * 3, zipNCursor.CurrentValue);

            var movedAtLE = zipNCursor.MoveAt(2, Lookup.LE);
            Assert.IsTrue(movedAtLE);
            Assert.AreEqual((100 + 4 + 6) * 2, zipNCursor.CurrentValue);

            var movedAtGE = zipNCursor.MoveAt(5, Lookup.GE);
            Assert.IsTrue(movedAtGE);
            Assert.AreEqual((100 + 10 + 15) * 5, zipNCursor.CurrentValue);

            var movedAtLT = zipNCursor.MoveAt(3, Lookup.LT);
            Assert.IsTrue(movedAtLT);
            Assert.AreEqual((100 + 4 + 6) * 2, zipNCursor.CurrentValue);
            movedAtLT = zipNCursor.MoveAt(1, Lookup.LT);
            Assert.IsTrue(!movedAtLT);

            var movedAtGT = zipNCursor.MoveAt(3, Lookup.GT);
            Assert.IsTrue(movedAtGT);
            Assert.AreEqual((100 + 10 + 15) * 5, zipNCursor.CurrentValue);
            movedAtGT = zipNCursor.MoveAt(7, Lookup.GT);
            Assert.IsTrue(!movedAtGT);
            int val;
            var hasGTValue = zipNCursor.TryGetValue(8, out val);
            Assert.IsTrue(hasGTValue);
            Assert.AreEqual((100 + 14 + 21) * 8, val);
        }
开发者ID:b-e-n-j,项目名称:Spreads,代码行数:60,代码来源:ZipNTests.cs

示例4: CouldMoveContinuousOnEmptyIntersect

        public void CouldMoveContinuousOnEmptyIntersect() {

            var sm1 = new SortedMap<int, int>(new Dictionary<int, int>() {
                //{ 1, 1}
            });
            var sm2 = new SortedMap<int, int>(new Dictionary<int, int>()
                {

                    { 1, 2},
                    { 2, 4},
                    { 3, 6},
                    { 5, 10},
                    { 7, 14}
                });


            var zipped = sm1.Repeat() + sm2.Repeat();
            var c1 = zipped.GetCursor();
            //Assert.IsFalse(c1.MoveNext());
            //Assert.IsFalse(c1.MoveFirst());
            var task = c1.MoveNext(CancellationToken.None);

            sm1.Add(6, 1);
            sm1.Add(8, 1);
            Thread.Sleep(50);
            task.Wait();
            Assert.AreEqual(TaskStatus.RanToCompletion, task.Status);
            Assert.AreEqual(6, c1.CurrentKey);
            Assert.AreEqual(15, c1.CurrentValue);

        }
开发者ID:b-e-n-j,项目名称:Spreads,代码行数:31,代码来源:ZipNTests.cs

示例5: CouldNotMoveAsyncContinuousOnEmptyZip

        public void CouldNotMoveAsyncContinuousOnEmptyZip() {

            var sm1 = new SortedMap<int, int>();
            var sm2 = new SortedMap<int, int>();
            sm1.IsMutable = false;
            sm2.IsMutable = false;

            var zipped = sm1.Repeat() + sm2.Repeat();
            var c1 = zipped.GetCursor();
            Assert.IsFalse(sm1.GetCursor().MoveNext(CancellationToken.None).Result);
            Assert.IsFalse(sm2.GetCursor().MoveNext(CancellationToken.None).Result);
            Assert.IsFalse(c1.MoveNext());
            Assert.IsFalse(c1.MoveFirst());
            var task = c1.MoveNext(CancellationToken.None);
            task.Wait();
            Assert.AreEqual(TaskStatus.RanToCompletion, task.Status);
            Assert.IsFalse(task.Result);
        }
开发者ID:b-e-n-j,项目名称:Spreads,代码行数:18,代码来源:ZipNTests.cs

示例6: ContinuousZipIsCorrectByRandomCheck

        public void ContinuousZipIsCorrectByRandomCheck() {
            var sw = new Stopwatch();

            var sm1 = new SortedMap<int, int>();
            var sm2 = new SortedMap<int, int>();


            var rng = new System.Random(31415926); //31415926

            var prev1 = 0;
            var prev2 = 0;

            for (int i = 0; i < 100000; i = i + 1) {
                prev1 = prev1 + rng.Next(1, 11);
                sm1.Add(prev1, prev1);
                prev2 = prev2 + rng.Next(1, 11);
                sm2.Add(prev2, prev2);
            }
            sm1.IsMutable = false;
            sm2.IsMutable = false;

            //Console.WriteLine("First map:");
            //foreach (var kvp in sm1)
            //{
            //    Console.WriteLine(kvp.Key);
            //}

            //Console.WriteLine("Second map:");
            //foreach (var kvp in sm2) {
            //    Console.WriteLine(kvp.Key);
            //}

            var series = new[] { sm1.Repeat(), sm2.Repeat(), };

            sw.Start();
            var allKeys = sm1.keys.Union(sm2.keys).OrderBy(x => x).ToArray();
            int[] expectedKeys = new int[allKeys.Length];
            int[] expectedValues = new int[allKeys.Length];
            var size = 0;
            for (int i = 0; i < allKeys.Length; i++) {
                var val = 0;
                KeyValuePair<int, int> temp;
                var hasFirst = sm1.TryFind(allKeys[i], Lookup.LE, out temp);
                if (hasFirst) {
                    val += temp.Value;
                    var hasSecond = sm2.TryFind(allKeys[i], Lookup.LE, out temp);
                    if (hasSecond) {
                        val += temp.Value;
                        expectedKeys[size] = allKeys[i];
                        expectedValues[size] = val;
                        size++;
                    }
                }
            }

            var expectedMap = SortedMap<int, int>.OfSortedKeysAndValues(expectedKeys, expectedValues, size);

            sw.Stop();

            //Console.WriteLine("Expected map:");
            //foreach (var kvp in expectedMap) {
            //    Console.WriteLine(kvp.Key + " ; " + kvp.Value);
            //}

            Console.WriteLine("Manual join, elapsed msec: {0}", sw.ElapsedMilliseconds);


            SortedMap<int, int> sum = new SortedMap<int, int>();

            for (int round = 0; round < 1; round++) {
                sw.Restart();
                var ser = series.Zip((k, varr) => varr.Sum());

                var cur = ser.GetCursor();
                while (cur.MoveNext()) {
                    sum.AddLast(cur.CurrentKey, cur.CurrentValue);
                }

                sw.Stop();
                Console.WriteLine("Zip join, elapsed msec: {0}", sw.ElapsedMilliseconds);
                //Console.WriteLine("StateCreation: {0}", RepeatCursor<int, int>.StateCreation);
                //Console.WriteLine("StateHit: {0}", RepeatCursor<int, int>.StateHit);
                //Console.WriteLine("StateMiss: {0}", RepeatCursor<int, int>.StateMiss);
            }



            //Console.WriteLine("Sync zip map:");
            //foreach (var kvp in sum) {
            //    Console.WriteLine(kvp.Key + " ; " + kvp.Value);
            //}
            Assert.AreEqual(expectedMap.Count, sum.Count, "Results of sync and expected must be equal");

            foreach (var kvp in expectedMap) {
                Assert.AreEqual(kvp.Value, sum[kvp.Key]);
            }

            for (int round = 0; round < 1; round++) {
                sw.Restart();
                var ser = series.Zip((k, varr) => varr.Sum());
//.........这里部分代码省略.........
开发者ID:b-e-n-j,项目名称:Spreads,代码行数:101,代码来源:ZipNTests.cs

示例7: ContinuousZipWithEmptySeriesIsEmpty

        public void ContinuousZipWithEmptySeriesIsEmpty() {
            var sm1 = new SortedMap<int, int>();
            var sm2 = new SortedMap<int, int>();

            var rp1 = sm1.Repeat();
            var rp2 = sm2.Repeat();

            var zip = rp1.Zip(rp2, (l, r) => l + r);
            Assert.AreEqual(0, zip.Count());

            sm1.Add(1, 1);
            var zip2 = rp1.Zip(rp2, (l, r) => l + r);
            Assert.AreEqual(0, zip2.Count());

            var cursor = zip.GetCursor();
            Assert.IsFalse(cursor.MoveNext());

            var cursor2 = zip2.GetCursor();
            Assert.IsFalse(cursor2.MoveNext());

            var fill = sm2.Fill(0);
            var zip3 = rp1.Zip(fill, (l, r) => l + r);
            Assert.AreEqual(1, zip3.Count());
        }
开发者ID:b-e-n-j,项目名称:Spreads,代码行数:24,代码来源:ZipNTests.cs

示例8: CouldZipContinuousInRealTimeWithOneShort

        public void CouldZipContinuousInRealTimeWithOneShort() {
            var sm1 = new SortedMap<DateTime, double>();
            var sm2 = new SortedMap<DateTime, double>();

            var count = 1000;


            for (int i = 0; i < count; i++) {
                sm1.Add(DateTime.UtcNow.Date.AddSeconds(i), i);
            }

            sm2.Add(DateTime.UtcNow.Date.AddSeconds(0), 2);
            sm2.Complete();

            Task.Run(() => {
                Thread.Sleep(1000);
                for (int i = count; i < count * 2; i++) {
                    sm1.Add(DateTime.UtcNow.Date.AddSeconds(i), i);
                    //Thread.Sleep(50);
                }

                sm1.Complete();
            });

            // this test measures isolated performance of ZipN, without ToSortedMap

            var sw = new Stopwatch();


            var series = new[] { sm1.Repeat(), sm2.Repeat() };

            sw.Start();
            var totalSum = 0.0;
            var sumCursor = series.Zip((k, varr) => varr.Sum()).GetCursor();
            var c = 0;
            while (c < 5 && sumCursor.MoveNext()) {
                Assert.AreEqual(c + 2, sumCursor.CurrentValue);
                totalSum += sumCursor.CurrentValue;
                c++;
            }


            Task.Run(async () => {
                while (await sumCursor.MoveNext(CancellationToken.None)) {
                    Assert.AreEqual(c + 2, sumCursor.CurrentValue);
                    Console.WriteLine("Value: " + sumCursor.CurrentValue);
                    totalSum += sumCursor.CurrentValue;
                    c++;
                }
                sw.Stop();
                Console.WriteLine("Elapsed msec: {0}", sw.ElapsedMilliseconds);
                Console.WriteLine("Total sum: {0}", totalSum);
            }).Wait();


        }
开发者ID:Applied-Duality,项目名称:Spreads,代码行数:56,代码来源:ZipNTests.cs

示例9: CouldZipMillionIntsWithMovePreviousContinuous

        public void CouldZipMillionIntsWithMovePreviousContinuous() {
            var sw = new Stopwatch();

            var sm1 = new SortedMap<int, int>();
            var sm2 = new SortedMap<int, int>();
            sm1.Add(0, 0);
            sm2.Add(0, 0);

            for (int i = 2; i < 100000; i = i + 2) {
                sm1.Add(i, i);
                sm2.Add(i + 1, i);
            }

            var series = new[] { sm1.Repeat(), sm2.Repeat(), };

            sw.Start();

            var sum = series.Zip((k, varr) => varr.Sum());
            var sumCursor = sum.GetCursor();
            var pos = 1000000 - 1;
            while (sumCursor.MovePrevious() && sumCursor.MovePrevious() && sumCursor.CurrentKey >= 2) {
                //Assert.AreEqual(pos * 2 - 2, sum[pos]);
                ////sumCursor.MovePrevious();
                //pos--;
                //pos--;
            }


            sw.Stop();
            //Console.WriteLine("Elapsed msec: {0}", sw.ElapsedMilliseconds);
            //for (int i = 2; i < 1000000; i = i + 2) {
            //    Assert.AreEqual(i * 2 - 2, sum[i]);
            //}

        }
开发者ID:b-e-n-j,项目名称:Spreads,代码行数:35,代码来源:ZipNTests.cs

示例10: CouldZipContinuousInRealTime

        public void CouldZipContinuousInRealTime() {

            var sm1 = new SortedMap<DateTime, double>();
            var sm2 = new SortedMap<DateTime, double>();

            var count = 100;

            for (int i = 0; i < count; i++) {
                sm1.Add(DateTime.UtcNow.Date.AddSeconds(i), i);
                sm2.Add(DateTime.UtcNow.Date.AddSeconds(i), i * 3);
            }
            sm1.IsMutable = true; // will mutate after the first batch

            Task.Run(() => {
                Thread.Sleep(1000);
                for (int i = count; i < count * 2; i++) {
                    sm1.Add(DateTime.UtcNow.Date.AddSeconds(i), i);
                    Thread.Sleep(50);
                }

                sm1.IsMutable = false; // stop mutating
                //Console.WriteLine("Set immutable");
            });

            Task.Run(() => {
                Thread.Sleep(950);
                for (int i = count; i < count * 2; i++) {
                    sm2.Add(DateTime.UtcNow.Date.AddSeconds(i), i * 3);
                    Thread.Sleep(50);
                }

                sm2.IsMutable = false; // stop mutating
                //Console.WriteLine("Set immutable");
            });

            // this test measures isolated performance of ZipN, without ToSortedMap
            Thread.Sleep(1050);
            var sw = new Stopwatch();


            var series = new[] { sm1.Repeat(), sm2.Repeat() };

            sw.Start();
            var totalSum = 0.0;
            var sumCursor = series.Zip((k, varr) => varr.Sum()).GetCursor();
            var c = 0;
            while (c < 5 && sumCursor.MoveNext()) {
                Assert.AreEqual(c * 4.0, sumCursor.CurrentValue);
                totalSum += sumCursor.CurrentValue;
                c++;
            }


            Task.Run(async () => {
                while (await sumCursor.MoveNext(CancellationToken.None)) {
                    if (Math.Abs(c * 4.0 - sumCursor.CurrentValue) <= 3.0) { // NB VolksWagening
                        // TODO deal with it somehow, e.g. with recalc of the last value, and explicitly document
                        Trace.TraceWarning("Zipping continuous series in real-time is inherently non-deterministic");
                    } else {
                        Assert.AreEqual(c * 4.0, sumCursor.CurrentValue);
                    }
                    Console.WriteLine("Value: " + sumCursor.CurrentValue);
                    totalSum += sumCursor.CurrentValue;
                    c++;
                }
                sw.Stop();
                Console.WriteLine("Elapsed msec: {0}", sw.ElapsedMilliseconds);
                Console.WriteLine("Total sum: {0}", totalSum);
            }).Wait();
            Thread.Sleep(100);
            sumCursor.Dispose();

        }
开发者ID:b-e-n-j,项目名称:Spreads,代码行数:73,代码来源:ZipNTests.cs

示例11: CouldRepeatMapSeries

        public void CouldRepeatMapSeries() {
            var sm = new SortedMap<DateTime, double>();
            var sm2 = new SortedMap<DateTime, double>();

            var count = 1000000;

            for (int i = 0; i < count; i++) {
                sm.Add(DateTime.UtcNow.Date.AddSeconds(i * 2), i);
            }

            for (int i = 0; i < count; i++) {
                sm2.Add(DateTime.UtcNow.Date.AddSeconds(i * 2 + 1), i);
            }

            var expected = 0.0;
            for (int i = 0; i < count; i++) {
                expected += i * 2 + 1 + 1;
            }
            OptimizationSettings.CombineFilterMapDelegates = false;
            var sw = new Stopwatch();
            sw.Start();
            var sum = (sm.Repeat().Map(x => x + 1.0).Repeat().Map(x => x + 1.0) + sm2).Values.Sum(); //
            sw.Stop();
            //Assert.AreEqual(expected, sum);
            Console.WriteLine("Repeat + zip, elapsed: {0}, ops: {1}", sw.ElapsedMilliseconds, (int)((double)count / (sw.ElapsedMilliseconds / 1000.0)));

        }
开发者ID:b-e-n-j,项目名称:Spreads,代码行数:27,代码来源:MissingValuesCursorsTests.cs

示例12: CouldRepeatEmptySeries

        public void CouldRepeatEmptySeries() {
            var sm = new SortedMap<DateTime, double>();

            var c = sm.Repeat().GetCursor();

            Assert.IsFalse(c.MoveNext());

        }
开发者ID:b-e-n-j,项目名称:Spreads,代码行数:8,代码来源:MissingValuesCursorsTests.cs

示例13: UnionKeysTest

        public void UnionKeysTest() {
            var sm1 = new SortedMap<int, int>();
            var sm2 = new SortedMap<int, int>();
            var zip = sm1.Repeat() + sm2.Repeat();
            var c = zip.GetCursor();


            sm1.Add(1, 1);
            Assert.IsFalse(c.MoveNext());
            sm2.Add(0, 0);
            Assert.IsTrue(c.MoveNext());
            Assert.AreEqual(1, c.CurrentKey);

            sm1.Add(0, 0);
            Assert.IsFalse(c.MoveNext());
            Assert.IsTrue(c.MovePrevious());
            Assert.AreEqual(0, c.CurrentKey);
            Assert.IsFalse(c.MovePrevious());
            Assert.IsTrue(c.MoveNext());
            Assert.AreEqual(1, c.CurrentKey);

            sm1.Add(3, 3);
            Assert.IsTrue(c.MoveNext());
            Assert.AreEqual(3, c.CurrentKey);
            Assert.AreEqual(3, c.CurrentValue);

            var t = Task.Run(async () => {
                return await c.MoveNext(CancellationToken.None);
            });
            Thread.Sleep(15);
            sm2.Add(4, 4);
            Assert.IsTrue(t.Wait(50));
            Assert.IsTrue(t.Result);
            Assert.AreEqual(4, c.CurrentKey);
            Assert.AreEqual(7, c.CurrentValue);
        }
开发者ID:Applied-Duality,项目名称:Spreads,代码行数:36,代码来源:ZipNTests.cs

示例14: CouldZipManyContinuousInRealTime

        public void CouldZipManyContinuousInRealTime() {
            //Assert.Inconclusive();
            //Trace.TraceWarning("volkswagening: this test hangs when started together with ZipN tests");
            //return;
            var sm1 = new SortedMap<DateTime, double>();
            var sm2 = new SortedMap<DateTime, double>();

            var count = 100000;

            for (int i = 0; i < count; i++) {
                sm1.Add(DateTime.UtcNow.Date.AddSeconds(i), i);
                sm2.Add(DateTime.UtcNow.Date.AddSeconds(i), i * 3);
            }

            var t1 = Task.Run(() => {
                try {
                    Thread.Sleep(1000);
                    for (int i = count; i < count * 2; i++) {
                        sm1.Add(DateTime.UtcNow.Date.AddSeconds(i), i);
                    }
                } finally {
                    sm1.Complete();
                    Console.WriteLine("sm1.Complete()");
                }
            });

            var t2 = Task.Run(() => {
                try {
                    Thread.Sleep(950);
                    for (int i = count; i < count * 2; i++) {
                        sm2.Add(DateTime.UtcNow.Date.AddSeconds(i), i * 3);
                    }
                } finally {
                    sm2.Complete();
                    Console.WriteLine("sm2.Complete()");
                }
            });

            // this test measures isolated performance of ZipN, without ToSortedMap

            var sw = new Stopwatch();


            var series = new[] { sm1.Repeat(), sm2.Repeat() };

            sw.Start();
            var totalSum = 0.0;
            var sumCursor = series.Zip((k, varr) => varr.Sum()).GetCursor();
            var c = 0;
            while (c < 5 && sumCursor.MoveNext()) {
                //Assert.AreEqual(c * 4.0, sumCursor.CurrentValue);
                totalSum += sumCursor.CurrentValue;
                c++;
            }

            var t3 = Task.Run(async () =>
            {
                var previous = sumCursor.CurrentKey;
                while (await sumCursor.MoveNext(CancellationToken.None)) {
                    //Assert.AreEqual(c * 4.0, sumCursor.CurrentValue);
                    //Console.WriteLine("Value: " + sumCursor.CurrentValue);
                    totalSum += sumCursor.CurrentValue;
                    c++;
                    Assert.IsTrue(sumCursor.CurrentKey > previous, "Next key is less than previous");
                    previous = sumCursor.CurrentKey;
                }
            });
            Task.WaitAll(t1, t2, t3);
            sw.Stop();
            Console.WriteLine("Elapsed msec: {0}", sw.ElapsedMilliseconds);
            Console.WriteLine("Total sum: {0}", totalSum);
            Assert.AreEqual(count * 2, sm1.Count);
            Assert.AreEqual(count * 2, sm2.Count);

        }
开发者ID:Applied-Duality,项目名称:Spreads,代码行数:75,代码来源:ZipNTests.cs

示例15: BugFromStrategies

        public void BugFromStrategies() {

            var sw = new Stopwatch();

            var sm1 = new SortedMap<int, int>();
            var sm2 = new SortedMap<int, int>();

            sm1.Add(0, 0);
            sm2.Add(-100500, 0);
            for (int i = 2; i < 100; i++) {
                sm1.Add(i, i);
                if (i % 10 == 0) {
                    sm2.Add(i, i);
                }
            }
            // assertion failure
            var repeated = sm2.Repeat().Fill(0);//.ToSortedMap();
            var result = repeated.Zip(sm1, (k, p, d) => p).Lag(1u); // .Fill(0)

            var cursor = result.GetCursor();
            Assert.IsTrue(cursor.MoveNext());

            var clone = cursor.Clone();
            //Assert.IsTrue(clone.MoveNext());
            //Assert.IsTrue(clone.MoveNext());


            var sm = result.ToSortedMap();
            Console.WriteLine(result.Count());


        }
开发者ID:b-e-n-j,项目名称:Spreads,代码行数:32,代码来源:ZipNTests.cs


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