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


C# LinkedList.GetEnumerator方法代码示例

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


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

示例1: getLCSGrid

        public static int[,] getLCSGrid(LinkedList<Behavior> sequenceA, LinkedList<Behavior> sequenceB)
        {
            int[,] grid = new int[sequenceA.Count + 1, sequenceB.Count + 1];
            int i;
            int j;

            for (i = 0; i < grid.GetLength(0); i++)
            {
                grid[i, 0] = 0;
            }
            for (i = 0; i < grid.GetLength(1); i++)
            {
                grid[0, i] = 0;
            }

            i = 1;
            for (LinkedList<Behavior>.Enumerator a = sequenceA.GetEnumerator(); a.MoveNext(); i++)
            {
                j = 1;
                for (LinkedList<Behavior>.Enumerator b = sequenceB.GetEnumerator(); b.MoveNext(); j++)
                {
                    if (a.Current.compareTo(b.Current) == 0)
                    {
                        grid[i, j] = grid[i-1, j-1] + 1;
                    }
                    else
                    {
                        grid[i, j] = Math.Max(grid[i, j - 1], grid[i - 1, j]);
                    }
                }
            }

            return grid;
        }
开发者ID:gripp,项目名称:psychic-octo-nemesis,代码行数:34,代码来源:SIMA.cs

示例2: Main

        private static void Main()
        {
            // LinkedList<string> -sasto moje zaradi polimorfizma
            IEnumerable<string> list = new LinkedList<string>(
                "1st element",
                new LinkedList<string>("2nd element", new LinkedList<string>("3rd element")));

            foreach (var item in list)
            {
                Console.WriteLine(item);
            }

            // ot metoda v LinkedList
            var enumerator = list.GetEnumerator();

            // pak se vliza v sastiat method, v koito i otogore vlizahme, defakto dolnite redove zamestvat foreacha
            while (enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.Current);
            }

            // enumerator.Reset();
            var nums = new CustomList<int>();
            nums.Add(5);
            nums.Add(2);
            nums.Add(4);
            nums.Add(2);
            nums.Add(1);
            foreach (var num in nums)
            {
                Console.WriteLine(num);
            }
        }
开发者ID:EBojilova,项目名称:CSharp-OOP-June-2015,代码行数:33,代码来源:ImplementingIEnumerableMain.cs

示例3: getMissingFilesForWidget

        private ArrayList getMissingFilesForWidget(LinkedList<FileInfo> filesCurWidget, ArrayList files)
        {
            IEnumerator ienumf = filesCurWidget.GetEnumerator();

            ArrayList missingFiles = new ArrayList();
            bool found = false;
            while (ienumf.MoveNext())
            {
                FileInfo finfo = (FileInfo)ienumf.Current;

                found = false;
                IEnumerator ienuml = files.GetEnumerator();
                while (ienuml.MoveNext())
                {
                    string localPath = (string)ienuml.Current;
                    if (localPath == Utils.normalizePathname(finfo.localPath))
                    {
                        found = true;
                        break;
                    }
                }

                if ( !found )
                {
                    missingFiles.Add(finfo.localPath);
                }
            }

            return missingFiles;
        }
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:30,代码来源:WidgetBrowserVcs.cs

示例4: AddDeclarations

 public void AddDeclarations(LinkedList<CSSDeclaration> declarations)
 {
     IEnumerator<CSSDeclaration> e = declarations.GetEnumerator();
     while (e.MoveNext()) {
         p_Declarations.AddLast(e.Current);
     }
     e.Dispose(); ;
 }
开发者ID:Lipsis,项目名称:Lipsis,代码行数:8,代码来源:DeclarationCollection.cs

示例5: SyntaxAnalyser

        public SyntaxAnalyser(string inputText)
        {
            input = new LinkedList<string>();
            foreach (char s in inputText)
            {
                input.AddLast(s.ToString());
            }
            isCorrect = true;
            enumerator = input.GetEnumerator();
            enumerator.Dispose();

        }
开发者ID:ptr92zet,项目名称:Math-Lingustics,代码行数:12,代码来源:SyntaxAnalyser.cs

示例6: Main

    static void Main(string[] args)
    {
        var k = 30;
        var names = File.ReadLines("first.txt");
        var list = new LinkedList<string>();

        foreach(var name in names){
          list.AddLast(name);
        }

        var e1 = list.GetEnumerator();
        var e2 = list.GetEnumerator();

        var i = 0;
        while(e1.MoveNext()!=false){
          i++;
          if (i>=k){
        e2.MoveNext();
          }
        }
        Console.WriteLine(e2.Current);
    }
开发者ID:slofurno,项目名称:cracking,代码行数:22,代码来源:main.cs

示例7: should_get_value_using_current_property

        public void should_get_value_using_current_property()
        {
            var collection = new LinkedList<int>(new[] {1, 2, 3});

            LinkedList<int>.Enumerator enumerator = collection.GetEnumerator();

            enumerator.MoveNext();

            int currentValue = enumerator.Current;

            // change the variable value to fix the test.
            const int expectedCurrentValue = 2;

            Assert.Equal(expectedCurrentValue, currentValue);
        }
开发者ID:chenbojian,项目名称:01_NewbieVillage,代码行数:15,代码来源:19_Enumeration.cs

示例8: LinkedListEnumerator

 public static void LinkedListEnumerator(long[] data)
 {
     LinkedList<long> testList = new LinkedList<long>();
     foreach (var l in data)
     {
         testList.Add(l);
     }
     var testlistenum = testList.GetEnumerator();
     var dataenum = data.GetEnumerator();
     for (int i = 0; i < data.Length; i++)
     {
         testlistenum.MoveNext();
         dataenum.MoveNext();
         Assert.AreEqual(testlistenum.Current, dataenum.Current);
     }
 }
开发者ID:EBojilova,项目名称:SoftUni-3,代码行数:16,代码来源:Problem7Tests.cs

示例9: IncrementToken

        public override bool IncrementToken()
        {
            if (Cache == null)
            {
                // fill cache lazily
                Cache = new LinkedList<AttributeSource.State>();
                FillCache();
                Iterator = Cache.GetEnumerator();
            }

            if (!Iterator.MoveNext())
            {
                // the cache is exhausted, return false
                return false;
            }
            // Since the TokenFilter can be reset, the tokens need to be preserved as immutable.
            RestoreState(Iterator.Current);
            return true;
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:19,代码来源:CachingTokenFilter.cs

示例10: TestEmptyLinkedListEnumerator

 public void TestEmptyLinkedListEnumerator()
 {
     LinkedList<Object> foo = new LinkedList<Object> ();
     IEnumerator<Object> enr = foo.GetEnumerator ();
     Assert.IsFalse (enr.MoveNext ());
 }
开发者ID:KommuSoft,项目名称:ZincOxide,代码行数:6,代码来源:BasicTests.cs

示例11: avg

 private double avg(LinkedList<double> list)
 {
     double sum = 0, count = 0;
     LinkedList<double>.Enumerator a = list.GetEnumerator();
     while(a.MoveNext()){
         sum += a.Current;
         count++;
     }
     return sum/count;
 }
开发者ID:gbarresi,项目名称:random_BCI,代码行数:10,代码来源:MazeShooterGame.cs

示例12: EnumerableTest

 [TestMethod] // IEnumerable
 public void EnumerableTest()
 {
     LinkedList<object> data = new LinkedList<object>();
     data.Append(8);
     data.Append(6);
     data.GetEnumerator();
 }
开发者ID:steeparts,项目名称:Muftiyev_Arthur_06,代码行数:8,代码来源:LinkedListTest.cs

示例13: findCore

        private void findCore(string query, bool deep, bool matchCase, bool matchWhole, LinkedList<Node> list, LinkedList<MarkupElement> buffer, bool textFind, bool attributeFind, bool attributeValue)
        {
            //check for valid call
            //if it's a text find AND attribute find, we actually call findCore twice
            //one to match attributes and pipe the result into a text find call
            if (textFind && attributeFind) {
                LinkedList<MarkupElement> pipe = new LinkedList<MarkupElement>();
                findCore(query, deep, matchCase, matchWhole, list, pipe, false, attributeFind, attributeValue);
                findCore(query, deep, matchCase, matchWhole, pipe, buffer, true, false, false);
                return;
            }
            if (!attributeFind && attributeValue) {
                throw new Exception("Illigal call, attributeValue cannot be true when attributeFind is false.");
            }

            //case insensitive? make the query lower case so we can compare two lower case strings together
            if (!matchCase) { query = query.ToLower(); }

            //enumerate over all the child nodes
            IEnumerator<Node> children = list.GetEnumerator();

            while (children.MoveNext()) {
                MarkupElement current = children.Current as MarkupElement;
                bool match = false;

                //is it an attribute find?
                //if so, iterate over all the attributes and find the name
                if (attributeFind) {
                    IEnumerator<MarkupAttribute> attrEnum = current.Attributes.GetEnumerator();
                    while (attrEnum.MoveNext()) {
                        MarkupAttribute attr = attrEnum.Current;
                        string attrCompare = (attributeValue ? attr.Value : attr.Name);
                        match = matchCore(attrCompare, query, matchCase, matchWhole);
                        if (match) { break; }
                    }

                    //clean up
                    attrEnum.Dispose();
                }
                //text find?
                else if (textFind && current is MarkupTextElement) {
                    match = matchCore(
                        (current as MarkupTextElement).Text,
                        query,
                        matchCase,
                        matchWhole);
                }
                else {
                    //tag compare
                    match = matchCore(current.TagName, query, matchCase, matchWhole);
                }

                //is it a match?
                if (match) {
                    buffer.AddLast(current);
                }

                //recursive?
                if (deep) {
                    findCore(
                        query,
                        deep,
                        matchCase,
                        matchWhole,
                        current.Children,
                        buffer,
                        textFind,
                        attributeFind,
                        attributeValue);
                }
            }

            //clean up
            children.Dispose();
        }
开发者ID:Lipsis,项目名称:Lipsis,代码行数:75,代码来源:MarkupElement.cs

示例14: Parse


//.........这里部分代码省略.........

                        //read the name
                        byte* attrNamePtr, attrNamePtrEnd;
                        if (readName(ref data, dataEnd, out attrNamePtr, out attrNamePtrEnd, false, tagHasQM, ref closeCharFound)) { break; }

                        //skip to the value
                        if (Helpers.SkipWhitespaces(ref data, dataEnd)) { break; }

                        //read the value
                        byte* attrValuePtr = data, attrValuePtrEnd = (byte*)NULLPTR;
                        if (*data == '=') {
                            data++;
                            if (Helpers.SkipWhitespaces(ref data, dataEnd)) { break; }

                            //read the value
                            readStringValue(ref data, dataEnd, out attrValuePtr, out attrValuePtrEnd, tagHasQM, ref closeCharFound);
                        }

                        //add the attribute
                        string valueString =
                            (attrValuePtrEnd == (byte*)0) ? null :
                            Helpers.ReadString(attrValuePtr, attrValuePtrEnd, encoder);
                        element.AddAttribute(
                            Helpers.ReadString(attrNamePtr, attrNamePtrEnd, encoder),
                            valueString);
                    }

                    #endregion

                    //skip to the end of the tag
                    while (data < dataEnd && *data != MarkupTAG_CLOSE) {
                        if (*data == MarkupTAG_SCOPECLOSE) { tagDoesTerminate = true; }
                        data++;
                    }
                    if (*data == MarkupTAG_CLOSE) { closeCharFound = true; }

                    #region create inner text if required
                    //is there text to be added before the element is added?
                    if (innerTextBufferPtr != innerTextBufferPtrEnd) {
                        //create the text element
                        if (!isEmptyData(innerTextBufferPtr, innerTextBufferPtrEnd - 1)) {
                            string str = Helpers.ReadString(innerTextBufferPtr, innerTextBufferPtrEnd, encoder);
                            if (current is MarkupTextElement) {
                               (current as MarkupTextElement).Text = str;
                            }
                            else {
                                current.AddChild(factory.CreateText(textTagName, str));
                            }
                        }
                    }

                    //reset
                    innerTextBufferPtr = data + 1;
                    innerTextBufferPtrEnd = data + 1;
                    #endregion

                    //is this a valid tag?
                    if (!closeCharFound) {
                        //just presume what we just processed was text
                        innerTextBufferPtrEnd = data;
                        continue;
                    }

                    //add the tag
                    current.AddChild(element);

                    //change the current name to the new element
                    //but only if the tag has not been terminated immidiately
                    //(otherwise there is no point adding to it.)
                    if (!tagDoesTerminate) {
                        current = element;
                        currentNamePtr = element.TagName;
                        currentName = currentNameList.AddLast(currentNamePtr);
                    }
                }

                innerTextBufferPtrEnd++;
                data++;
            }

            //is there text left?
            if (innerTextBufferPtrEnd != innerTextBufferPtr &&
                innerTextBufferPtrEnd > innerTextBufferPtr &&
                !isEmptyData(innerTextBufferPtr, innerTextBufferPtrEnd - 1)) {
                    current.AddChild(factory.CreateText(
                        textTagName,
                        Helpers.ReadString(
                            innerTextBufferPtr,
                            innerTextBufferPtrEnd,
                            encoder)));

            }

            //clean up
            IEnumerator<STRPTR> destructCurrentNameList = currentNameList.GetEnumerator();
            while (destructCurrentNameList.MoveNext()) {
                destructCurrentNameList.Current.Destroy();
            }
            destructCurrentNameList.Dispose();
        }
开发者ID:Lipsis,项目名称:Lipsis,代码行数:101,代码来源:MarkupDocument.cs

示例15: substituteExist

        private bool substituteExist(char name, LinkedList<ArithmeticSubstitute> subs, out ArithmeticSubstitute found)
        {
            found = default(ArithmeticSubstitute);

            //look for the name
            IEnumerator<ArithmeticSubstitute> e = subs.GetEnumerator();
            while (e.MoveNext()) {
                ArithmeticSubstitute current = e.Current;
                if (current.Name == name) {
                    e.Dispose();
                    found = current;
                    return true;
                }
            }

            //not found
            e.Dispose();
            return false;
        }
开发者ID:Lipsis,项目名称:Lipsis,代码行数:19,代码来源:Queue.cs


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