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


C# ArrayList.Reverse方法代码示例

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


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

示例1: GroupByPriorities

    public static FishArbitratedBehaviour[][] GroupByPriorities(ArrayList behaviours)
    {
        // map priority -> behaviours
        Hashtable dict = new Hashtable();
        foreach(FishArbitratedBehaviour beh in behaviours){
            int priority = beh.priority;
            ArrayList list;
            if(!dict.ContainsKey(priority)){
                list = new ArrayList();
                dict[priority] = list;
            }else{
                list = (ArrayList)dict[priority];
            }
            list.Add(beh);
        }

        // arrange behaviour groups in execution order (highest priorities first)
        ArrayList priorities = new ArrayList(dict.Keys);
        FishArbitratedBehaviour[][] grouped = new FishArbitratedBehaviour[priorities.Count][];

        priorities.Sort();
        priorities.Reverse();
        for(int i = 0; i < priorities.Count; i++){
            int priority = (int)priorities[i];
            ArrayList group = (ArrayList)dict[priority];
            grouped[i] = (FishArbitratedBehaviour[])group.ToArray(typeof(FishArbitratedBehaviour));
        }

        return grouped;
    }
开发者ID:IlyaBokovenko,项目名称:spear-fishing-old,代码行数:30,代码来源:FishArbitratedBehaviour.cs

示例2: Start

    // Use this for initialization
    void Start()
    {
        ArrayList list = new ArrayList ();
        int score = PlayerPrefs.GetInt ("endScore");

        for (int i = 1; i<=10; i++) {
            key = "highScore" + i;
            keyscore = PlayerPrefs.GetInt(key);
            list.Add(keyscore);

            //PlayerPrefs.SetInt (key, 0);
        }

        lowestScore = PlayerPrefs.GetInt ("highScore10");
        Debug.Log ("lowest score" + lowestScore);

        if (score > lowestScore)
        {
            list.Add (score);
            list.Sort ();
            list.Reverse();
            list.RemoveAt(10);

            for (int i = 1; i<=10; i++) {
                key = "highScore" + i;
                PlayerPrefs.SetInt(key, (int)list[i-1]);
            }
        }
    }
开发者ID:hollidev,项目名称:afroleg,代码行数:30,代码来源:ScoreNew.cs

示例3: SortingArrayList

 //按条件对数组进行排序
 public static ArrayList SortingArrayList(ArrayList List)
 {
     if (List == null) return List;
     ArrayList NewList = null;
     List.Reverse();
     NewList = List;
     return NewList;
 }
开发者ID:kosmos-zhang,项目名称:erp-aspnet,代码行数:9,代码来源:GridViewOprt.cs

示例4: CalculatePath

 private static ArrayList CalculatePath(Node node)
 {
     ArrayList list = new ArrayList();
     while (node != null) {
         list.Add(node);
         node = node.parent;
     }
     list.Reverse();
     return list;
 }
开发者ID:tianfdh,项目名称:AStar,代码行数:10,代码来源:AStar.cs

示例5: reconstructPath

 public ArrayList reconstructPath(Dictionary<GameObject, GameObject> cameFrom, GameObject current)
 {
     ArrayList totalPath = new ArrayList();
     totalPath.Add(current);
     while (cameFrom.ContainsKey(current)) {
         current = cameFrom[current];
         totalPath.Add(current);
     }
     totalPath.Reverse();
     return totalPath;
 }
开发者ID:fataku,项目名称:Ambrosia,代码行数:11,代码来源:MovementHandler.cs

示例6: Main

 static void Main()
 {
     ArrayList ar = new ArrayList(10);
     ar.Add("이승만");
     ar.Add("박정희");
     ar.Add("최규하");
     ar.Add("전두환");
     ar.Add("노태우");
     ar.Add("김영삼");
     ar.Add("김대중");
     ar.Add("노무현");
     ar.Add("이명박");
     foreach (object o in ar) Console.Write(o + ",");
     ar.Sort();
     ar.Reverse();
     Console.WriteLine();
     foreach (object o in ar) Console.Write(o + ",");
 }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:18,代码来源:Program.cs

示例7: Start

    // Use this for initialization
    void Start()
    {
        //creates an array of an undetermined size and type
        ArrayList aList = new ArrayList();

        //create an array of all objects in the scene
        Object[] AllObjects = GameObject.FindObjectsOfType(typeof(Object)) as Object[];

        //iterate through all objects
        foreach (Object o in AllObjects)
        {
            if (o.GetType() == typeof(GameObject))
            {
                aList.Add(o);
            }
        }

        if (aList.Contains(SpecificObject))
        {
            Debug.Log(aList.IndexOf(SpecificObject));
        }

        if (aList.Contains(gameObject))
        {
            aList.Remove(gameObject);
        }

        //initialize the AllGameObjects array
        AllGameObjects = new GameObject[aList.Count];

        //copy the list to the array
        DistanceComparer dc = new DistanceComparer();
        dc.Target = gameObject;
        aList.Sort(dc);

        aList.CopyTo(AllGameObjects);
        ArrayList sorted = new ArrayList();
        sorted.AddRange(messyInts);
        sorted.Sort();
        sorted.Reverse();
        sorted.CopyTo(messyInts);
    }
开发者ID:kurtzhang,项目名称:UnityProjects,代码行数:43,代码来源:ArrayLists.cs

示例8: CmdMoveUnitToTile

    public void CmdMoveUnitToTile( GameObject unit, GameObject src, GameObject dest)
    {
        Pathfinder finder = GameObject.Find ("GameMaster").GetComponent<Pathfinder>();
        Dictionary<HexTile, HexTile> thePath = finder.GetPathToTile( unit.GetComponent<Moveable>(),
                                                                     src.GetComponent<HexTile>(),
                                                                     dest.GetComponent<HexTile>());

        //		unit.transform.position = dest.transform.position + new Vector3( 32, 0, 0);

        Debug.Log( thePath.Count + " elements. " + thePath.ToString());

        //		foreach( KeyValuePair<HexTile, HexTile> tile in thePath)
        //		{
        //			Debug.Log( tile.Key.transform.position + " to " + tile.Value.transform.position);
        //		}

        HexTile theTile = dest.GetComponent<HexTile>();
        int j = 0;
        ArrayList pathOrder = new ArrayList() { theTile.gameObject};
        while (theTile != src.GetComponent<HexTile>())
        {
            theTile = thePath[ theTile];
            pathOrder.Add ( theTile.gameObject);
            Debug.Log( j++ + ": " + theTile);
        }

        pathOrder.Reverse ();

        src.GetComponent<HexTile>().occupants.Remove( unit);
        unit.GetComponent<Moveable>().occupying = src.GetComponent<HexTile>();
        unit.GetComponent<Moveable>().pathToTake = pathOrder;

        //		unit.GetComponent<Moveable>().occupying = dest.GetComponent<HexTile>();
        //		dest.GetComponent<HexTile>().occupants.Add( unit);
        //		unit.transform.position = dest.transform.position;

        RpcIssueMoveOrderToClients( unit, src, dest);
    }
开发者ID:gelum,项目名称:TBA,代码行数:38,代码来源:Player_CommandList.cs

示例9: GoalPathesI

    private static void GoalPathesI(GBSearchModule module,
		ArrayList goalpathes, DBNode node, Stack path)
    {
        if (node == null)
            return;

        if (module.IsGoal (node.State)) {
            ArrayList newGoalPath = new ArrayList ();

            foreach (DBNode pNode in path)
                newGoalPath.Add (pNode);

            newGoalPath.Reverse ();

            newGoalPath.Add (node);
            goalpathes.Add (newGoalPath);

            return;
        }

        foreach (DBNode child in node.Children) {
            path.Push (node);
            GoalPathesI (module, goalpathes, child, path);
            path.Pop ();
        }
    }
开发者ID:gomoku,项目名称:Stahlfaust---Gomoku-AI-player,代码行数:26,代码来源:GBThreat.cs

示例10: reconstructPath

 public ArrayList reconstructPath(cell start, cell goal)
 {
     ArrayList result = new ArrayList();
         bool fl = false;
         int k = 0;
         cell current = (cell)allset[allset.Count-1];
         while(!(fl) && k<allset.Count)
         {
             /*result.Add(current);
             if(current.parent == null){
                 fl = true;
             }else{
                 current = current.parent;
             }*/
             current = (cell)allset[k];
             result.Add(allset[k]);
             k++;
         }
         result.Reverse();
         return result;
 }
开发者ID:Brauny74,项目名称:Lab,代码行数:21,代码来源:FindPathClass.cs

示例11: Calc


//.........这里部分代码省略.........
				} else if (AstarPath.active.simplify == Simplify.Simple) {
					if (active.gridGenerator != GridGenerator.Grid && active.gridGenerator != GridGenerator.Texture) {
						Debug.LogError ("Simplification can not be used with grid generators other than 'Texture' and 'Grid', excpect weird results");
					}
					Debug.LogWarning ("The Simple Simplification is broken");
					/*Node c = end;
					int p = 0;
					//Follow the parents of all nodes to the start point, but only add nodes if there is a change in direction
					int preDir = c.invParentDirection;
					ArrayList a = new ArrayList ();
					a.Add (c);
					while (c.parent != null) {
						
						if (c.parent.invParentDirection != preDir) {
							a.Add (c.parent);
							preDir = c.parent.invParentDirection;
						}
						
						c = c.parent;
						p++;
						
						if (c == start) {
							
							break;
						}
						
						if (p > 300) {
							Debug.LogError ("Preventing possible infinity loop");
							break;
						}
					}
					
					//Then reverse it so the start node gets the first place in the array
					a.Reverse ();
					
					path = a.ToArray (typeof (Node)) as Node[];
				
					t += Time.realtimeSinceStartup-startTime;
					
					//@Performance Debug calls cost performance
					Debug.Log ("A* Pathfinding Completed Succesfully : End code 2\nTime: "+t+" Seconds\nFrames "+frames+"\nAverage Seconds/Frame "+(t/frames)+"\nPoints:"+path.Length+" (simplified)"+"\nSearched Nodes"+closedNodes+"\nPath Length (G score) Was "+end.g);*/
					
				} else if (AstarPath.active.simplify == Simplify.Full) {
					if (active.gridGenerator != GridGenerator.Grid && active.gridGenerator != GridGenerator.Texture) {
						Debug.LogError ("Simplification can not be used with grid generators other than 'Texture' and 'Grid' excpect weird results");
					}
					
					Node c = end;
					ArrayList a = new ArrayList ();
					a.Add (c);
					int p = 0;
					
					//Follow the parents of all nodes to the start point
					while (c.parent != null) {
						a.Add (c.parent);
						
						c = c.parent;
						p++;
						if (c == start) {
							
							break;
						}
						
						//@Performance this IF is almost completely unnecessary
						//if (p > 300) {
						//	Debug.LogError ("Preventing possible infinity loop, remove this code if you have very long paths");
开发者ID:hyper-active,项目名称:virtual-reality,代码行数:67,代码来源:AstarPath.cs

示例12: GetPath

 private ArrayList<string> GetPath(string url, out int numDomainParts, out int numTldParts, bool fullPath)
 {
     string leftPart;
     ArrayList<string> path;
     ArrayList<KeyDat<string, string>> queryParsed;
     UrlNormalizer.ParseUrl(url, out leftPart, out path, out queryParsed);
     string host = leftPart.Split(':')[1].Trim('/');
     string[] tldParts = UrlNormalizer.GetTldFromDomainName(host).Split('.');
     numTldParts = tldParts.Length;
     string[] hostParts = host.Split('.');
     numDomainParts = hostParts.Length;
     ArrayList<string> branch = new ArrayList<string>(hostParts);
     branch.Reverse();
     branch.AddRange(path);
     //Console.WriteLine(branch);
     if (!fullPath && path.Count > 0)
     {
         branch.RemoveAt(branch.Count - 1);
     }
     return branch;
 }
开发者ID:project-first,项目名称:latino,代码行数:21,代码来源:UrlTree.cs

示例13: runTest

 public virtual bool runTest()
 {
     int iCountErrors = 0;
     int iCountTestcases = 0;
     Console.Error.WriteLine( strName + ": " + strTest + " runTest started..." );
     ArrayList arrList = null;
     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",
     };
     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 ArrayList1" );
                 ++iCountErrors;
                 break;
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10001: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Reverse entire array list" );
         try
         {
             arrList.Reverse( 0, arrList.Count );
             for ( int ii = 0; ii < arrList.Count; ++ii )
             {
                 if ( strHeroes[ii].CompareTo( (String)arrList[arrList.Count-ii-1] ) != 0 )
                 {
                     String strInfo = strTest + " error: ";
                     strInfo = strInfo + "Expected hero <"+ strHeroes[ii] + "> ";
                     strInfo = strInfo + "Returned hero <"+ (String)arrList[ii+arrList.Count-1] + "> ";
                     Console.WriteLine( strTest+ "E_202: " + strInfo );
                     ++iCountErrors;
                     break;
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10002: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Attempt bogus Reverse using negative index" );
         try
         {
             arrList.Reverse( -100, arrList.Count );
             Console.WriteLine( strTest+ "E_303: Expected ArgumentException" );
             ++iCountErrors;
             break;
         }
         catch (ArgumentException ex)
         {
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10003: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Attempt Reverse using out of range index" );
         try
         {
             arrList.Reverse( 1000, arrList.Count );
             Console.WriteLine( strTest+ "E_404: Expected ArgumentException" );
             ++iCountErrors;
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co2482reverse.cs

示例14: Test02

        public void Test02()
        {
            //--------------------------------------------------------------------------
            // Variable definitions.
            //--------------------------------------------------------------------------
            ArrayList arrList = null;

            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",
            };

            //
            // Construct array list.
            //
            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)ArrayList.FixedSize(arrList).Clone(),
                                        (ArrayList)arrList.GetRange(0, arrList.Count).Clone(),
                                        (ArrayList)ArrayList.Synchronized(arrList).Clone()};

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

                //
                // []  Reverse entire array list.
                //
                // Reverse entire array list.
                arrList.Reverse();

                // Verify items have been reversed.
                for (int ii = 0; ii < arrList.Count; ++ii)
                {
                    Assert.Equal(0, strHeroes[ii].CompareTo((String)arrList[arrList.Count - ii - 1]));
                }

                //[]Team review feedback - Reversing lists of varying sizes inclusing 0
                arrList = new ArrayList();
                arrList.Reverse();

                arrList = new ArrayList();
                for (int i = 0; i < 1; i++)
                    arrList.Add(i);

                arrList.Reverse();
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:75,代码来源:ReverseTests.cs

示例15: GetTopPosition

        /// <summary>
        /// Calculates the top, non-grabStack position.
        /// </summary>
        /// <returns></returns>
        private float GetTopPosition()
        {
            float topPosition = 0;
            ArrayList<Block> blocks = new ArrayList<Block>();
            blocks.AddAll(currentStack);
            blocks.Reverse();

            foreach (Block block in blocks)
            {
                // See if we are moving or if we have no height
                if (block.IsMoving || block.Height == 0)
                    continue;

                // Grab this one
                topPosition = block.TopPosition;
                break;
            }
            return topPosition;
        }
开发者ID:dmoonfire,项目名称:cutegod,代码行数:23,代码来源:PlayMode.cs


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