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


C# Iterator.HasNext方法代码示例

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


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

示例1: TestHasNext

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

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

            Assert.IsTrue(iter.HasNext(1));
            Assert.IsTrue(iter.HasNext(2));
            Assert.IsTrue(iter.HasNext(3));
            Assert.IsFalse(iter.HasNext(4));
        }
开发者ID:oivoodoo,项目名称:lunar-unity-plugin,代码行数:14,代码来源:IteratorTest.cs

示例2: 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:Gittre,项目名称:HeadFirstDesignPatterns,代码行数:27,代码来源:Waitress.cs

示例3: 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

示例4: TestSkip

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

            int iterations = 0;

            Iterator<string> iter = new Iterator<string>(list);
            while (iter.HasNext())
            {
                iter.Skip();
                ++iterations;
            }

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

示例5: 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

示例6: PrintMenu

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

示例7: 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

示例8: IterateChildrenMethod

 /// <summary>Handles the iteration of the children or qualfier</summary>
 /// <param name="iterator">an iterator</param>
 /// <returns>Returns if there are more elements available.</returns>
 private bool IterateChildrenMethod(Iterator iterator)
 {
     if (this._enclosing.skipSiblings)
     {
         // setSkipSiblings(false);
         this._enclosing.skipSiblings = false;
         this.subIterator = Sharpen.Collections.EmptyList().Iterator();
     }
     // create sub iterator for every child,
     // if its the first child visited or the former child is finished
     if ((!this.subIterator.HasNext()) && iterator.HasNext())
     {
         XMPNode child = (XMPNode)iterator.Next();
         this.index++;
         this.subIterator = new XMPIteratorImpl.NodeIterator(this._enclosing, child, this.path, this.index);
     }
     if (this.subIterator.HasNext())
     {
         this.returnProperty = (XMPPropertyInfo)this.subIterator.Next();
         return true;
     }
     else
     {
         return false;
     }
 }
开发者ID:Sicos1977,项目名称:n-metadata-extractor,代码行数:29,代码来源:XMPIteratorImpl.cs

示例9: printMenu

 private void printMenu(Iterator iter)
 {
     while (iter.HasNext())
     {
         MenuItem menuItem = (MenuItem)iter.Next();
         Console.WriteLine(menuItem.getName() + "\n" + menuItem.getPrice());
     }
 }
开发者ID:alandias01,项目名称:Console_practice,代码行数:8,代码来源:Iterator2(UsesMenuInterface).cs

示例10: getSuggestions

        private static string[] getSuggestions(string commandLine, IList<string> tokens)
        {
            Iterator<string> iter = new Iterator<string>(tokens);

            CCommand cmd = CRegistery.FindCommand(iter.Next());
            if (cmd == null)
            {
                return EMPTY_SUGGESTIONS; // no command found
            }

            while (iter.HasNext())
            {
                string token = iter.Next();
                int iterPos = iter.Position; // store position to revert for the case if option skip fails

                // first try to parse options
                if (token.StartsWith("--")) // long option
                {
                    string optionName = token.Substring(2);
                    if (SkipOption(iter, cmd, optionName)) continue;

                    iter.Position = iterPos;
                    return getSuggestedOptions(iter, cmd, optionName, "--");
                }
                else if (token.StartsWith("-") && !StringUtils.IsNumeric(token)) // short option
                {
                    string optionName = token.Substring(1);
                    if (SkipOption(iter, cmd, optionName)) continue;

                    iter.Position = iterPos;
                    return getSuggestedOptions(iter, cmd, optionName, "-");
                }

                if (iter.HasNext())
                {
                    return EMPTY_SUGGESTIONS; // TODO: add multiple args suggestion support
                }

                return getSuggestedArgs(commandLine, cmd, token);
            }

            return getSuggestedArgs(commandLine, cmd, "");
        }
开发者ID:mswf,项目名称:game-a-week,代码行数:43,代码来源:CommandAutocompletion.cs

示例11: 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

示例12: SkipOption

        private static bool SkipOption(Iterator<string> iter, Option opt)
        {
            Type type = opt.Target.FieldType;

            if (type.IsArray)
            {
                Array arr = (Array) opt.Target.GetValue(opt);
                if (arr != null)
                {
                    int index;
                    int length = arr.Length;
                    for (index = 0; index < length && iter.HasNext(); ++index)
                    {
                        string value = iter.Next();
                        if (!IsValidOptionString(value))
                        {
                            return false;
                        }
                    }

                    return index == length;
                }

                return false;
            }

            if (type == typeof(int) || 
                type == typeof(float) || 
                type == typeof(string))
            {
                if (iter.HasNext())
                {
                    string value = iter.Next();
                    return IsValidOptionString(value);
                }

                return false;
            }

            if (type == typeof(bool))
            {
                return true;
            }

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

示例13: TestSkipSomeElements

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

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

            Assert.IsTrue(iter.HasNext());
            iter.Skip();

            Assert.IsTrue(iter.HasNext());
            Assert.AreEqual(list [1], iter.Next());

            Assert.IsTrue(iter.HasNext());
            iter.Skip();

            Assert.IsFalse(iter.HasNext());
        }
开发者ID:oivoodoo,项目名称:lunar-unity-plugin,代码行数:20,代码来源:IteratorTest.cs

示例14: 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

示例15: 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


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