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


C# Iterator.Next方法代码示例

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


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

示例1: TestNext

 public void TestNext()
 {
     IEnumerable<DayOfWeek> collection = new DayOfWeek[] { DayOfWeek.Monday, DayOfWeek.Friday };
     var iterator = new Iterator<DayOfWeek>(collection.GetEnumerator());
     Assert.AreEqual(DayOfWeek.Monday, iterator.Next());
     Assert.AreEqual(DayOfWeek.Friday, iterator.Next());
     ExceptionAssert.Throws<InvalidOperationException>(() => iterator.Next());
 }
开发者ID:tssoft,项目名称:TsSoft.Commons,代码行数:8,代码来源:IteratorTest.cs

示例2: DisplayMemberList

 public static void DisplayMemberList(Iterator.IIterator iterator)
 {
     while (!iterator.IsDone())
     {
         Console.WriteLine(iterator.Next());
     }
 }
开发者ID:dmoelgaard,项目名称:design-patterns-simple,代码行数:7,代码来源:Program.cs

示例3: A_GroupedWithin_must_group_elements_within_the_duration

        public void A_GroupedWithin_must_group_elements_within_the_duration()
        {
            this.AssertAllStagesStopped(() =>
            {
                var input = new Iterator<int>(Enumerable.Range(1, 10000));
                var p = TestPublisher.CreateManualProbe<int>(this);
                var c = TestSubscriber.CreateManualProbe<IEnumerable<int>>(this);

                Source.FromPublisher(p)
                    .GroupedWithin(1000, TimeSpan.FromSeconds(1))
                    .To(Sink.FromSubscriber(c))
                    .Run(Materializer);

                var pSub = p.ExpectSubscription();
                var cSub = c.ExpectSubscription();

                cSub.Request(100);

                var demand1 = (int)pSub.ExpectRequest();
                for (var i = 1; i <= demand1; i++)
                    pSub.SendNext(input.Next());

                var demand2 = (int)pSub.ExpectRequest();
                for (var i = 1; i <= demand2; i++)
                    pSub.SendNext(input.Next());

                var demand3 = (int)pSub.ExpectRequest();
                c.ExpectNext().ShouldAllBeEquivalentTo(Enumerable.Range(1, demand1 + demand2));
                for (var i = 1; i <= demand3; i++)
                    pSub.SendNext(input.Next());

                c.ExpectNoMsg(TimeSpan.FromMilliseconds(300));
                c.ExpectNext()
                    .ShouldAllBeEquivalentTo(Enumerable.Range(demand1 + demand2 + 1, demand3));
                c.ExpectNoMsg(TimeSpan.FromMilliseconds(300));
                pSub.ExpectRequest();

                var last = input.Next();
                pSub.SendNext(last);
                pSub.SendComplete();

                c.ExpectNext().Should().HaveCount(1).And.HaveElementAt(0, last);
                c.ExpectComplete();
                c.ExpectNoMsg(TimeSpan.FromMilliseconds(200));

            }, Materializer);
        }
开发者ID:rogeralsing,项目名称:akka.net,代码行数:47,代码来源:FlowGroupedWithinSpec.cs

示例4: TestHasNext

 public void TestHasNext()
 {
     var collection = Enum.GetValues(typeof(DayOfWeek)).Cast<DayOfWeek>();
     var iterator = new Iterator<DayOfWeek>(collection.GetEnumerator());
     for (int i = 0; i < collection.Count(); i++)
     {
         Assert.IsTrue(iterator.HasNext);
         iterator.Next();
     }
     Assert.IsFalse(iterator.HasNext);
 }
开发者ID:tssoft,项目名称:TsSoft.Commons,代码行数:11,代码来源:IteratorTest.cs

示例5: PrintMenu

        public string PrintMenu(Iterator iterator)
        {
            StringBuilder sb = new StringBuilder();
            while(iterator.HasNext())
            {
                MenuItem menuItem = (MenuItem)iterator.Next();

                sb.Append(menuItem.Name + ", ");
                sb.Append(menuItem.Price + " -- ");
                sb.Append(menuItem.Description + "\n");
            }

            return sb.ToString();
        }
开发者ID:alannet,项目名称:example,代码行数:14,代码来源:Waitress.cs

示例6: TestForwardIteration

        public void TestForwardIteration()
        {
            List<string> list = new List<string>();
            list.Add("1");
            list.Add("2");
            list.Add("3");

            int index = 0;

            Iterator<string> iter = new Iterator<string>(list);
            while (iter.HasNext())
            {
                Assert.AreEqual(list[index++], iter.Next());
            }

            Assert.AreEqual(list.Count, index);
        }
开发者ID:oivoodoo,项目名称:lunar-unity-plugin,代码行数:17,代码来源:IteratorTest.cs

示例7: Main

  public static void Main(string[] args)
  {
    // Build a collection
    Collection collection = new Collection();
    collection[0] = new Item( "Item 0" );
    collection[1] = new Item( "Item 1" );
    collection[2] = new Item( "Item 2" );
    collection[3] = new Item( "Item 3" );
    collection[4] = new Item( "Item 4" );
    collection[5] = new Item( "Item 5" );
    collection[6] = new Item( "Item 6" );
    collection[7] = new Item( "Item 7" );
    collection[8] = new Item( "Item 8" );

    // Create iterator
    Iterator iterator = new Iterator( collection );
    
    // Skip every other item
    iterator.Step = 2;

    // Loop using iterator
    for( Item item = iterator.First(); 
         !iterator.IsDone(); item = iterator.Next() )
    {
      Console.WriteLine( item.Name );
    }

    Console.Read();
  }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:29,代码来源:Iterator_RealWorld.cs

示例8: A_GroupedWithin_must_reset_time_window_when_max_elements_reached

        public void A_GroupedWithin_must_reset_time_window_when_max_elements_reached()
        {
            var input = new Iterator<int>(Enumerable.Range(1, 10000));
            var upstream = TestPublisher.CreateProbe<int>(this);
            var downstream = TestSubscriber.CreateProbe<IEnumerable<int>>(this);

            Source.FromPublisher(upstream)
                .GroupedWithin(3, TimeSpan.FromSeconds(2))
                .To(Sink.FromSubscriber(downstream))
                .Run(Materializer);

            downstream.Request(2);
            downstream.ExpectNoMsg(TimeSpan.FromMilliseconds(1000));

            Enumerable.Range(1,4).ForEach(_=>upstream.SendNext(input.Next()));
            downstream.Within(TimeSpan.FromMilliseconds(1000), () =>
            {
                downstream.ExpectNext().ShouldAllBeEquivalentTo(new[] {1, 2, 3});
                return NotUsed.Instance;
            });

            downstream.ExpectNoMsg(TimeSpan.FromMilliseconds(1500));

            downstream.Within(TimeSpan.FromMilliseconds(1000), () =>
            {
                downstream.ExpectNext().ShouldAllBeEquivalentTo(new[] {4});
                return NotUsed.Instance;
            });

            upstream.SendComplete();
            downstream.ExpectComplete();
            downstream.ExpectNoMsg(TimeSpan.FromMilliseconds(100));
        }
开发者ID:rogeralsing,项目名称:akka.net,代码行数:33,代码来源:FlowGroupedWithinSpec.cs

示例9: A_GroupedWithin_must_buffer_groups_until_requested_from_downstream

        public void A_GroupedWithin_must_buffer_groups_until_requested_from_downstream()
        {
            var input = new Iterator<int>(Enumerable.Range(1, 10000));
            var p = TestPublisher.CreateManualProbe<int>(this);
            var c = TestSubscriber.CreateManualProbe<IEnumerable<int>>(this);

            Source.FromPublisher(p)
                .GroupedWithin(1000, TimeSpan.FromSeconds(1))
                .To(Sink.FromSubscriber(c))
                .Run(Materializer);

            var pSub = p.ExpectSubscription();
            var cSub = c.ExpectSubscription();

            cSub.Request(1);

            var demand1 = (int)pSub.ExpectRequest();
            for (var i = 1; i <= demand1; i++)
                pSub.SendNext(input.Next());
            c.ExpectNext().ShouldAllBeEquivalentTo(Enumerable.Range(1, demand1));

            var demand2 = (int)pSub.ExpectRequest();
            for (var i = 1; i <= demand2; i++)
                pSub.SendNext(input.Next());
            c.ExpectNoMsg(TimeSpan.FromMilliseconds(300));
            cSub.Request(1);
            c.ExpectNext().ShouldAllBeEquivalentTo(Enumerable.Range(demand1 + 1, demand2));

            pSub.SendComplete();
            c.ExpectComplete();
            c.ExpectNoMsg(TimeSpan.FromMilliseconds(100));
        }
开发者ID:rogeralsing,项目名称:akka.net,代码行数:32,代码来源:FlowGroupedWithinSpec.cs

示例10: NextArg

        public static string NextArg(Iterator<string> iter)
        {
            if (iter.HasNext())
            {
                string arg = StringUtils.UnArg(iter.Next());
                if (!IsValidArg(arg))
                {
                    throw new CCommandException("Invalid arg: " + arg);
                }

                return arg;
            }

            throw new CCommandException("Unexpected end of args");
        }
开发者ID:oivoodoo,项目名称:lunar-unity-plugin,代码行数:15,代码来源:CCommandUtils.cs

示例11: CompileError

 public CompileError(String message, Iterator<Token> at)
     : base(message + " " + (at.AtEnd() ? "NULL" : at.Next().ToString()))
 {
 }
开发者ID:Blecki,项目名称:EtcScript,代码行数:4,代码来源:CompileError.cs

示例12: PrintVegetarianMenu

 private void PrintVegetarianMenu(Iterator iterator)
 {
     while (iterator.HasNext())
     {
         MenuItem menuItem = (MenuItem)iterator.Next();
         if (menuItem.Vegetarian)
         {
             Console.WriteLine(menuItem.Name);
             Console.WriteLine("\t\t" + menuItem.Price);
             Console.WriteLine("\t" + menuItem.Description);
         }
     }
 }
开发者ID:ronymaychan,项目名称:demos,代码行数:13,代码来源:MenuTestDrive.cs

示例13: getSuggestedOptions

        private static string[] getSuggestedOptions(Iterator<string> iter, CCommand cmd, string optNameToken, string prefix)
        {
            List<Option> optionsList = new List<Option>(); // TODO: reuse list

            // list options
            bool useShort = prefix.Equals("-");
            if (useShort)
            {
                cmd.ListShortOptions(optionsList, optNameToken);
                optionsList.Sort(delegate(Option op1, Option op2) {
                    return op1.ShortName.CompareTo(op2.ShortName);
                });
            }
            else
            {
                cmd.ListOptions(optionsList, optNameToken);
                optionsList.Sort(delegate(Option op1, Option op2) {
                    return op1.Name.CompareTo(op2.Name);
                });
            }

            if (optionsList.Count > 1) // multiple options available
            {
                return getSuggestedOptions(optionsList, useShort);
            }

            if (optionsList.Count == 1) // single option available
            {
                Option opt = optionsList[0];

                if (isOptionNameMatch(opt, optNameToken, useShort)) // option name already matched - try values
                {
                    if (opt.HasValues()) // option has predefined values?
                    {
                        if (iter.HasNext()) // has value token?
                        {
                            return opt.ListValues(iter.Next());
                        }

                        return opt.Values;
                    }

                    if (iter.HasNext())
                    {
                        return EMPTY_SUGGESTIONS; // don't suggest option value
                    }
                }

                return singleSuggestion(getSuggestedOption(opt, useShort)); // suggest option`s name
            }

            return EMPTY_SUGGESTIONS;
        }
开发者ID:mswf,项目名称:game-a-week,代码行数:53,代码来源:CommandAutocompletion.cs

示例14: IsVegetarian

 private bool IsVegetarian(string name, Iterator iterator)
 {
     while (iterator.HasNext())
     {
         MenuItem menuItem = (MenuItem)iterator.Next();
         if (menuItem.Name.Equals(name))
         {
             if (menuItem.Vegetarian)
             {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:ronymaychan,项目名称:demos,代码行数:15,代码来源:MenuTestDrive.cs

示例15: TestSkipMultiple

        public void TestSkipMultiple()
        {
            List<string> list = new List<string>();
            list.Add("1");
            list.Add("2");
            list.Add("3");

            Iterator<string> iter = new Iterator<string>(list);

            iter.Skip(2);
            Assert.IsTrue(iter.HasNext());
            Assert.AreEqual(list[2], iter.Next());
        }
开发者ID:oivoodoo,项目名称:lunar-unity-plugin,代码行数:13,代码来源:IteratorTest.cs


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