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


C# ArrayList.GetEnumerator方法代码示例

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


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

示例1: writeEntry

    public void writeEntry(ArrayList entry)
    {
        mutex.WaitOne();

        IEnumerator line = entry.GetEnumerator();
        while (line.MoveNext())
           Console.WriteLine(line.Current);

        Console.WriteLine();

        mutex.ReleaseMutex();
    }
开发者ID:jin55132,项目名称:TCPCSharp,代码行数:12,代码来源:ConsoleLogger.cs

示例2: AddVegetation

    public static int AddVegetation(string filename)
    {
        string[] lines = OpenTextFile (filename);
        string trimmedLine;
        string result;

        Vector3 trans= Vector3.zero;
        ArrayList points= new ArrayList();
        int typeVegetation;

          		int n = 0;
        //		int lineNumber = 0;
        foreach (string line in lines) {
        //			Debug.Log (++lineNumber);
            trimmedLine = line.Trim();
            result = MatchItem(trimmedLine, "translation ");
            if ((null!=result) ) { trans = stringToVector3 (result); }
            result = MatchItem(trimmedLine, "points [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "pointsRemplis [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "typeVegetation ");
            if (null!=result) {
                typeVegetation=int.Parse(result);

                IEnumerator e = points.GetEnumerator();
                while (e.MoveNext()) {
                    n++;
                    GameObject tree = EditorUtility.InstantiatePrefab (prefabTrees[typeVegetation]) as GameObject;
                    tree.transform.parent=meshTrees.transform;

                    Vector3 v = (Vector3)e.Current+trans;
                    v.x=-v.x;
                    tree.transform.position=v;

                }

            }
        }
        return n;
    }
开发者ID:Tilg,项目名称:toulmystery,代码行数:41,代码来源:VegetationMesh.cs

示例3: Main

    public static int Main(String[] args)
    {
        ArrayList objList = new ArrayList();
        objList.Add("hey");
        objList.Add(null);

        IEnumerator ienum = objList.GetEnumerator();
        int iCounter = 0;
        while (ienum.MoveNext())
        {
            iCounter++;
            Console.WriteLine(iCounter.ToString());
        }
        if (iCounter == 2)
        {
            Console.WriteLine("Passed");
            return 100;
        }
        else
        {
            Console.WriteLine("Failed");
            return 1;
        }
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:24,代码来源:b06811.cs

示例4: TestArrayListWrappers02

        public void TestArrayListWrappers02()
        {
            //--------------------------------------------------------------------------
            // Variable definitions.
            //--------------------------------------------------------------------------
            ArrayList arrList = null;
            int ii = 0;
            bool bGetNext = false;
            object o1;

            IEnumerator ien1;

            //
            // Construct array lists.
            //
            arrList = new ArrayList((ICollection)strHeroes);

            //Adapter, GetRange, Synchronized, ReadOnly returns a slightly different version of 
            //BinarySearch, Following variable cotains each one of these types of array lists

            ArrayList[] arrayListTypes = {
                                    (ArrayList)arrList.Clone(),
                                    (ArrayList)ArrayList.Adapter(arrList).Clone(),
                                    (ArrayList)arrList.GetRange(0, arrList.Count).Clone(),
                                    (ArrayList)ArrayList.Synchronized(arrList).Clone(),
                                    (ArrayList)(new MyArrayList((ICollection) strHeroes))};

            IEnumerator enu = null;
            foreach (ArrayList arrayListType in arrayListTypes)
            {
                arrList = arrayListType;
                //
                // [] Add the ArrayList itself to the ArrayList
                //
                try
                {
                    arrList.Add(arrList);
                    enu = arrList.GetEnumerator();

                    int index;

                    index = 0;
                    while (enu.MoveNext())
                    {
                        Assert.StrictEqual(enu.Current, arrList[index]);
                        ++index;
                    }

                    enu.Reset();

                    index = 0;
                    while (enu.MoveNext())
                    {
                        Assert.StrictEqual(enu.Current, arrList[index]);
                        ++index;
                    }
                }
                finally
                {
                    arrList.RemoveAt(arrList.Count - 1);
                }

                //
                // []  Vanila - Obtain and verify enumerator.
                //
                // Obtain the enumerator for the test range.
                enu = arrList.GetEnumerator();
                IEnumerator enuClone = arrList.GetEnumerator();

                IEnumerator[] enuArray = { enu, enuClone };

                //Verify both this instance and the cloned copy
                foreach (IEnumerator enumerator in enuArray)
                {
                    enu = enumerator;

                    for (int i = 0; i < 2; i++)
                    {
                        Assert.NotNull(enu);

                        // Verify the enumerator.
                        for (ii = 0; ; ii++)
                        {
                            bGetNext = enu.MoveNext();
                            if (bGetNext == false)
                                break;

                            Assert.Equal(0, strHeroes[ii].CompareTo((string)enu.Current));
                        }

                        Assert.Equal(strHeroes.Length, ii);

                        bGetNext = enu.MoveNext();
                        Assert.False(bGetNext);
                        Assert.False(enu.MoveNext());
                        Assert.False(enu.MoveNext());
                        Assert.False(enu.MoveNext());

                        enu.Reset();
                    }
//.........这里部分代码省略.........
开发者ID:er0dr1guez,项目名称:corefx,代码行数:101,代码来源:GetEnumeratorTests.cs

示例5: createTestIntfPrx

 private static TestIntfPrx createTestIntfPrx(ArrayList adapters)
 {
     ArrayList endpoints = new ArrayList();
     TestIntfPrx obj = null;
     IEnumerator p = adapters.GetEnumerator();
     while(p.MoveNext())
     {
         obj = ((RemoteObjectAdapterPrx)p.Current).getTestIntf();
         foreach(Ice.Endpoint e in obj.ice_getEndpoints())
         {
             endpoints.Add(e);
         }
     }
     return TestIntfPrxHelper.uncheckedCast(
         obj.ice_endpoints((Ice.Endpoint[])endpoints.ToArray(typeof(Ice.Endpoint))));
 }
开发者ID:bholl,项目名称:zeroc-ice,代码行数:16,代码来源:AllTests.cs

示例6: AddVegetation

    static void AddVegetation(string filename)
    {
        string[] lines = OpenTextFile (filename);
        string trimmedLine;
        string result;
        int maxTrees = 10000;

        Vector3 trans= Vector3.zero;
        ArrayList points= new ArrayList();
        int typeVegetation;

           		Terrain terrain = getMainTerrain();

           		GameObject ft = GameObject.Find("ForTrees");
         		Terrain[] ters = ft.GetComponentsInChildren<Terrain>();

        Terrain t=getNextFreeTerrain(ters, maxTrees);
        TerrainData	terraindata = t.terrainData;
        TreeInstance tree;
        List<TreeInstance> newTrees = new List<TreeInstance>(terraindata.treeInstances);

        foreach (string line in lines) {
            trimmedLine = line.Trim();
            result = MatchItem(trimmedLine, "translation ");
            if (null!=result)  { trans = stringToVector3 (result); }
            result = MatchItem(trimmedLine, "points [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "pointsRemplis [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "typeVegetation ");
            if (null!=result) {
                typeVegetation=int.Parse(result);

                IEnumerator e = points.GetEnumerator();
                float rnd;
                while (e.MoveNext()) {

                    tree = new TreeInstance();
                    tree.position = WorldToTerrain(terrain,(Vector3)e.Current+trans);

                    tree.prototypeIndex = typeVegetation;
                    rnd= 0.5f*(Random.value-0.5f);
                    tree.widthScale = 1.0f+rnd;
                    tree.heightScale = 1.0f+rnd;

                    Color c = Color.white;
                    c[0] = 0.92f+Random.value*0.08f;
                    c[1] = 0.92f+Random.value*0.08f;
                    c[2] = 0.92f+Random.value*0.08f;
                    tree.color = c;

                    tree.lightmapColor = Color.white;

                    treeCount++;
                    newTrees.Add(tree);

                    if (newTrees.Count == maxTrees) {
                        terraindata.treeInstances= newTrees.ToArray();
                        t=getNextFreeTerrain(ters, maxTrees);
                        terraindata = t.terrainData;
                        newTrees = new List<TreeInstance>(terraindata.treeInstances);
                    }
                }

            }
        }
        terraindata.treeInstances= newTrees.ToArray();
    }
开发者ID:Tilg,项目名称:toulmystery,代码行数:68,代码来源:VegetationMultiTerrains.cs

示例7: Shade

 public virtual Color Shade(Vector3D p, Vector3D n, Vector3D v, ArrayList lights, 
     ArrayList objects, Color bgnd)
 {
     IEnumerator lightSources = lights.GetEnumerator();
     float r = 0;
     float g = 0;
     float b = 0;
     while (lightSources.MoveNext())
     {
         Light light = (Light)lightSources.Current;
         if (light.lightType == Light.AMBIENT)
         {
             r += ka * ir * light.ir;
             g += ka * ig * light.ig;
             b += ka * ib * light.ib;
         }
         else
         {
             Vector3D l;
             if (light.lightType == Light.POINT)
             {
                 l = new Vector3D(light.lvec.x - p.x, light.lvec.y - p.y, light.lvec.z - p.z);
                 l.Normalize();
             }
             else
             {
                 l = new Vector3D(-light.lvec.x, -light.lvec.y, -light.lvec.z);
             }
             // Check if the surface point is in shadow
             Vector3D poffset = new Vector3D(p.x + TINY * l.x, p.y + TINY * l.y, p.z + TINY *
                 l.z);
             Ray shadowRay = new Ray(poffset, l);
             if (shadowRay.Trace(objects))
             {
                 break;
             }
             float lambert = Vector3D.Dot(n, l);
             if (lambert > 0)
             {
                 if (kd > 0)
                 {
                     float diffuse = kd * lambert;
                     r += diffuse * ir * light.ir;
                     g += diffuse * ig * light.ig;
                     b += diffuse * ib * light.ib;
                 }
                 if (ks > 0)
                 {
                     lambert *= 2;
                     float spec = v.Dot(lambert * n.x - l.x, lambert * n.y - l.y, lambert * n.z - l.z);
                     if (spec > 0)
                     {
                         spec = ks * ((float)Math.Pow((double)spec, (double)ns));
                         r += spec * light.ir;
                         g += spec * light.ig;
                         b += spec * light.ib;
                     }
                 }
             }
         }
     }
     // Compute illumination due to reflection
     if (kr > 0)
     {
         float t = v.Dot(n);
         if (t > 0)
         {
             t *= 2;
             Vector3D reflect = new Vector3D(t * n.x - v.x, t * n.y - v.y, t * n.z - v.z);
             Vector3D poffset = new Vector3D(p.x + TINY * reflect.x, p.y + TINY * reflect.y, p
                 .z + TINY * reflect.z);
             Ray reflectedRay = new Ray(poffset, reflect);
             if (reflectedRay.Trace(objects))
             {
                 Color rcolor = reflectedRay.Shade(lights, objects, bgnd);
                 r += kr * rcolor.GetRed();
                 g += kr * rcolor.GetGreen();
                 b += kr * rcolor.GetBlue();
             }
             else
             {
                 r += kr * bgnd.GetRed();
                 g += kr * bgnd.GetGreen();
                 b += kr * bgnd.GetBlue();
             }
         }
     }
     // Add code for refraction here
     r = (r > 1f) ? 1f : r;
     g = (g > 1f) ? 1f : g;
     b = (b > 1f) ? 1f : b;
     return new Color(r, g, b);
 }
开发者ID:waitingcheung,项目名称:concolic-walk,代码行数:93,代码来源:RayTrace.cs

示例8: AddVegetation

    public static void AddVegetation(string filename)
    {
        string[] lines = OpenTextFile (filename);
        string trimmedLine;
        string result;

        Vector3 trans= Vector3.zero;
        ArrayList points= new ArrayList();
        int typeVegetation=0;

           		Terrain terrain = getMainTerrain("TerrainArbres");
        TerrainData	terraindata = terrain.terrainData;
        TreeInstance tree;
        List<TreeInstance> newTrees = new List<TreeInstance>(terraindata.treeInstances);

        Vector3 deltaY=Vector3.zero;
        deltaY.y+=0.0f;

        //		int lineNumber = 0;
        foreach (string line in lines) {
        //			Debug.Log (++lineNumber);
            trimmedLine = line.Trim();
            result = MatchItem(trimmedLine, "translation ");
            if ((null!=result) ) { trans = stringToVector3 (result); }
            result = MatchItem(trimmedLine, "points [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "pointsRemplis [");
            if (null!=result) { points = decodeArrayOfPoints(result); }
            result = MatchItem(trimmedLine, "typeVegetation ");
            if (null!=result) {
                typeVegetation=int.Parse(result);

                IEnumerator e = points.GetEnumerator();
                float rnd;
                while (e.MoveNext()) {

                    // make more random
                    if ((typeVegetation<=11) && (typeVegetation!=6)  && (typeVegetation!=7)  && (typeVegetation!=8)) {
                        while ((rnd=Random.value)==1.0f);
                        typeVegetation = (typeVegetation/3)*3+(int) (rnd*3);
                    }

                    tree = new TreeInstance();
                    tree.position = WorldToTerrain(terrain,(Vector3)e.Current+trans+deltaY);

                    tree.prototypeIndex = typeVegetation;

                    if (typeVegetation==18) Debug.Log ("invalide vegetation");

                    if (typeVegetation<=5) rnd =  0.3f*(Random.value-1.0f)-0.1f;
                    else if (typeVegetation<=8) rnd =  0.2f*(Random.value-1.0f);
                    else if (typeVegetation==9) rnd =  0.2f*(Random.value-1.0f);
                    else rnd= 0.25f*(Random.value-1.0f);
        //		rnd=0.0f;

                    if ((typeVegetation>=6) && (typeVegetation<=8)) tree.widthScale = 1.0f;
                    else tree.widthScale = 1.0f+rnd;
                    tree.heightScale = 1.0f+rnd;

                    Color c = Color.white;
                    c[0] = 0.92f+Random.value*0.08f;
                    c[1] = 0.92f+Random.value*0.08f;
                    c[2] = 0.92f+Random.value*0.08f;
                    tree.color = c;

                    tree.lightmapColor = Color.white;

                    // 1, 3, 4, 5

                    //if (typeVegetation==5)
                    newTrees.Add(tree);
                }

            }
        }
        terraindata.treeInstances= newTrees.ToArray();
    }
开发者ID:Tilg,项目名称:toulmystery,代码行数:77,代码来源:VegetationMonoTerrain.cs

示例9: Main

    static void Main(string[] args)
    {
        AssConfig config = new AssConfig();

            IList assemblyList = new ArrayList();
            IList outputList = new ArrayList();
            config.loadBundles(assemblyList, outputList);
            AssemblyBundle assemblyBundle = new AssemblyBundle(assemblyList);

            IEnumerator outputEnum = outputList.GetEnumerator();
            while (outputEnum.MoveNext()) {
                //String outputType = (String)outputEnum.Current;
                //Console.WriteLine(outputEnum.Current.GetType());
                OutputType outputType = (OutputType)outputEnum.Current;
                if (outputType.getOutputType() == "All") {
                    showAllAssemblyDependencies(assemblyBundle, outputType.getFile());
                } else if (outputType.getOutputType() == "Analyzed") {
                    showAllAnalyzedAssemblyDependencies(assemblyBundle, outputType.getFile());
                } else if (outputType.getOutputType() == "xml") {
                    outputXml(assemblyBundle, outputType.getFile());
                }
            }
    }
开发者ID:pragkirk,项目名称:assemblyanalyzer,代码行数:23,代码来源:Analyzer.cs

示例10: Trace

 public virtual bool Trace(ArrayList objects)
 {
     IEnumerator objList = objects.GetEnumerator();
     t = MAX_T;
     @object = null;
     while (objList.MoveNext())
     {
         Renderable @object2 = (Renderable)objList.Current;
         @object2.Intersect(this);
     }
     return (@object != null);
 }
开发者ID:waitingcheung,项目名称:concolic-walk,代码行数:12,代码来源:RayTrace.cs

示例11: get_type

    Type get_type(XInterfaceTypeDescription2 xType)
    {
        if (xType.getName() == "com.sun.star.uno.XInterface")
        {
            return typeof(System.Object);
        }

        string cts_name = to_cts_name(xType.getName());
        Type ret_type = get_type(cts_name, false /* no exc */);
        if (ret_type == null)
        {
            TypeBuilder type_builder;

            TypeAttributes attr = (TypeAttributes.Public |
                                   TypeAttributes.Interface |
                                   TypeAttributes.Abstract |
                                   TypeAttributes.AnsiClass);

            ArrayList baseTypes = new ArrayList();
            if (xType.getBaseTypes().Length > 0)
            {
                foreach (XInterfaceTypeDescription2 xIfaceTd
                         in xType.getBaseTypes())
                {
                    if (!(xIfaceTd.getName() == "com.sun.star.uno.XInterface"))
                    {
                        baseTypes.Add(xIfaceTd);
                    }
                }

                Type[] base_interfaces = new Type[baseTypes.Count];

                int index = 0;
                for (IEnumerator iter = baseTypes.GetEnumerator(); iter.MoveNext();
                     index++)
                {
                    base_interfaces[index] =
                        get_type((XInterfaceTypeDescription2) iter.Current);
                }
                type_builder = m_module_builder.DefineType(
                    cts_name, attr, null, base_interfaces);
            }
            else
            {
                Console.WriteLine(
                    "warning: IDL interface {0} is not derived from " +
                    "com.sun.star.uno.XInterface!", xType.getName());
                type_builder = m_module_builder.DefineType(cts_name, attr);
            }

            // insert to be completed
            iface_entry entry = new iface_entry();
            entry.m_xType = xType;
            entry.m_type_builder = type_builder;
            m_incomplete_ifaces.Add(cts_name, entry);

            // type is incomplete
            ret_type = type_builder;
        }
        return ret_type;
    }
开发者ID:jcorrius,项目名称:go-oo-mingw32-soc,代码行数:61,代码来源:TypeEmitter.cs

示例12: WriteBuffer

    public void WriteBuffer(ArrayList data) {
	IEnumerator iter = data.GetEnumerator();
	while (iter.MoveNext()) {
	    writer.WriteLine((String)iter.Current);
	}
    }
开发者ID:fkarb,项目名称:pythonnet,代码行数:6,代码来源:callconvutil.cs

示例13: TestArrayListWrappers01

        public void TestArrayListWrappers01()
        {
            //--------------------------------------------------------------------------
            // Variable definitions.
            //--------------------------------------------------------------------------
            ArrayList arrList = null;
            int ii = 0;
            int start = 3;
            int count = 15;
            bool bGetNext = false;
            object[] tempArray1;

            //
            // Construct array lists.
            //
            arrList = new ArrayList((ICollection)strHeroes);
            Assert.NotNull(arrList);

            //Adapter, GetRange, Synchronized, ReadOnly returns a slightly different version of 
            //BinarySearch, Following variable cotains each one of these types of array lists

            ArrayList[] arrayListTypes = {
                                    (ArrayList)arrList.Clone(),
                                    (ArrayList)ArrayList.Adapter(arrList).Clone(),
                                    (ArrayList)ArrayList.FixedSize(arrList).Clone(),
                                    (ArrayList)arrList.GetRange(0, arrList.Count).Clone(),
                                    (ArrayList)ArrayList.ReadOnly(arrList).Clone(),
                                    (ArrayList)ArrayList.Synchronized(arrList).Clone()};

            IEnumerator enu;
            foreach (ArrayList arrayListType in arrayListTypes)
            {
                arrList = arrayListType;

                // Obtain the enumerator for the test range.
                enu = (IEnumerator)arrList.GetEnumerator(start, count);
                Assert.NotNull(enu);

                // Verify the enumerator.
                for (ii = start; ii < start + count; ++ii)
                {
                    bGetNext = enu.MoveNext();
                    if (bGetNext == false)
                        break;

                    Assert.Equal(0, strHeroes[ii].CompareTo((string)enu.Current));
                }

                ii -= start;
                Assert.Equal(count, ii);

                bGetNext = enu.MoveNext();
                Assert.False(bGetNext);
                Assert.False(enu.MoveNext());
                Assert.False(enu.MoveNext());
                Assert.False(enu.MoveNext());

                // Obtain and verify enumerator with 0 count");
                // Obtain the enumerator for the test range.
                enu = (IEnumerator)arrList.GetEnumerator(start, 0);
                Assert.False(enu.MoveNext());
                Assert.False(enu.MoveNext());
                Assert.False(enu.MoveNext());

                enu.Reset();
                Assert.Throws<InvalidOperationException>(() =>
                {
                    object test = enu.Current;
                });

                Assert.False(enu.MoveNext());
                Assert.False(enu.MoveNext());
                Assert.False(enu.MoveNext());

                //
                // []  Make Sure both MoveNext and Reset throw InvalidOperationException if underlying collection has been modified but Current should not throw
                //
                if (!arrList.IsReadOnly)
                {
                    object origValue = arrList[arrList.Count - 1];

                    // [] MoveNext and Reset throw if collection has been modified
                    try
                    {
                        IEnumerator enu1 = (IEnumerator)arrList.GetEnumerator(start, count);
                        enu1.MoveNext();

                        arrList[arrList.Count - 1] = "Underdog";
                        object myValue = enu1.Current;

                        Assert.Throws<InvalidOperationException>(() => enu1.MoveNext());
                        Assert.Throws<InvalidOperationException>(() => enu1.Reset());

                    }
                    finally
                    {
                        arrList[arrList.Count - 1] = origValue;
                    }
                }

//.........这里部分代码省略.........
开发者ID:er0dr1guez,项目名称:corefx,代码行数:101,代码来源:GetEnumeratorTests.cs

示例14: runTest

 public virtual bool runTest()
 {
     int iCountErrors = 0;
     int iCountTestcases = 0;
     Console.Error.WriteLine( strName + ": " + strTest + " runTest started..." );
     ArrayList arrList = null;
     int ii = 0;
     int start = 3;
     int count = 15;
     bool bGetNext = false;
     String [] strHeroes =
         {
             "Aquaman",
             "Atom",
             "Batman",
             "Black Canary",
             "Captain America",
             "Captain Atom",
             "Catwoman",
             "Cyborg",
             "Flash",
             "Green Arrow",
             "Green Lantern",
             "Hawkman",
             "Huntress",
             "Ironman",
             "Nightwing",
             "Robin",
             "SpiderMan",
             "Steel",
             "Superman",
             "Thor",
             "Wildcat",
             "Wonder Woman",
     };
     String [] strResult =
         {
             "Aquaman",
             "Atom",
             "Batman",
             "Superman",
             "Thor",
             "Wildcat",
             "Wonder Woman",
     };
     do
     {
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Construct ArrayList" );
         try
         {
             arrList = new ArrayList( (ICollection) strHeroes );
             if ( arrList == null )
             {
                 Console.WriteLine( strTest+ "E_101: Failed to construct new ArrayList" );
                 ++iCountErrors;
                 break;
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10001: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Obtain and verify enumerator" );
         try
         {
             IEnumerator enu = (IEnumerator) arrList.GetEnumerator( start, count );
             if ( enu == null )
             {
                 Console.WriteLine( strTest+ "E_303: Failed to construct enumerator" );
                 ++iCountErrors;
                 break;
             }
             for ( ii = start; ii < start + count; ++ii )
             {
                 bGetNext = enu.MoveNext();
                 if ( bGetNext == false )
                     break;
                 if ( strHeroes[ii].CompareTo( (String)enu.Current ) != 0 )
                 {
                     String strInfo = strTest + " error: ";
                     strInfo = strInfo + "Expected Hero <"+ strHeroes[ii] + "> ";
                     strInfo = strInfo + "Returned Hero <"+ (String)enu.Current + "> ";
                     Console.WriteLine( strTest+ "E_404: " + strInfo );
                     ++iCountErrors;
                     break;
                 }
             }
             ii -= start;
             if ( ii != count )
             {
                 String strInfo = strTest + " error: ";
                 strInfo = strInfo + "Enumeration discrepancy\n";
                 strInfo = strInfo + "Expected Loop count==" + count;
                 strInfo = strInfo + "Returned Loop count==" + ii;
                 Console.WriteLine( strTest+ "E_303: Enumeration discrepancy.Failed to construct enumerator" );
                 ++iCountErrors;
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co2468getenumerator_ii.cs

示例15: testIterationOfClassWith1intArrayListWithIterator

    /**
     * testIterationOfStringListWithIterator.
     *
     * @return
     */
    public static long testIterationOfClassWith1intArrayListWithIterator()
    {
        ClassWith1intb classWith1int = new ClassWith1intb();
        IList list = new ArrayList(SIZE);
        for (int j = SIZE; j != 0; j--)
        {
            list.Add(classWith1int);
        }
        int count = 0;
        DateTime start = DateTime.Now;
        for (int i = TESTS_LIST; i != 0; i--)
        {
            for (IEnumerator enumerator = list.GetEnumerator(); enumerator.MoveNext(); )
            {
                ClassWith1intb classWith1intb = (ClassWith1intb)enumerator.Current;

                // Write to force cpp not to optimize the code, never executed
                if (i % 2 == 2)
                {
                    classWith1intb.Int1 = i;
                }
                count += classWith1intb.Int1;
            }
        }
        DateTime end = DateTime.Now;
        TimeSpan executionTime = end - start;
        Console.WriteLine("[CollectionTest], Iteration of " + TESTS_LIST + " ArrayList(" + SIZE + ") With Iterator  for (IEnumerator enumerator = list.GetEnumerator()  enumerator.MoveNext()   )   iterator.hasNext()  ) count += ((ClassWith1intb)enumerator.Current).Int1  , count=" + count + ", snapshot time,"
            + executionTime.TotalMilliseconds);
        return (long)executionTime.TotalMilliseconds;
    }
开发者ID:alexandrenavarro,项目名称:benchmark-languages,代码行数:35,代码来源:CollectionTest.cs


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