Reverse() public method

public Reverse ( ) : void
return void
Example #1
1
        public static void WriteException(System.Exception e)
        {
            ArrayList messages = new ArrayList();
            while (e != null)
            {
                messages.Add(e);
                e = e.InnerException;
            }
            Console.WriteLine(" ");
            Console.WriteLine("------- System.Exception ----------------------------- ");
            messages.Reverse();

            foreach (System.Exception ex in messages)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine(" ");
            Console.WriteLine("----- Details -----");
            foreach (System.Exception ex in messages)
            {
                Console.WriteLine("Message..........: " + ex.Message);
                Console.WriteLine("Stact trace......: " + ex.StackTrace);
                Console.WriteLine("TargetSite.......: " + ex.TargetSite.Name);
                Console.WriteLine("Source...........: " + ex.Source);
                Console.WriteLine(" ");
            }
        }
        private void SetBoardList()
        {
            boardlist.Items.Clear();
            studentboardlist.Clear();

            studentboardlist = service.StudentBoardRead();
            studentboardlist.Reverse();
            string[][] array = new string[studentboardlist.Count][];
            string[] boardinfo = new string[6];
            int maxcount = studentboardlist.Count;

            if (studentboardlist.Count >= MaxBoardCount)
            {
                for (int i = 0; i < MaxBoardCount; i++)
                {
                    boardinfo = studentboardlist[i].ToString().Split('\a');

                    array[i] = boardinfo;
                    boardlist.Items.Add(new BoardInfo { Number = maxcount - i, Name = array[i][2], Title = array[i][0], Date = array[i][5] });
                }
            }
            else
            {
                for (int i = 0; i < studentboardlist.Count; i++)
                {
                    boardinfo = studentboardlist[i].ToString().Split('\a');

                    array[i] = boardinfo;
                    boardlist.Items.Add(new BoardInfo { Number = maxcount - i, Name = array[i][2], Title = array[i][0], Date = array[i][5] });
                }
            }
            studentboardlist.Reverse(); //==> 게시판 정보를 빼올때 알맞은놈을 가져오기 위함
        }
        static void Main(string[] args)
        {
            ArrayList al = new ArrayList();

            al.Add(new ShoppinCartItem("Car", 5000));
            al.Add(new ShoppinCartItem("Book", 30));
            al.Add(new ShoppinCartItem("Phone", 80));
            al.Add(new ShoppinCartItem("Computer", 1000));

            al.Sort();

            foreach(ShoppinCartItem item in al)
            {
                Console.WriteLine(item.ItemName + " " + item.Price);
            }

            al.Reverse();

            foreach(ShoppinCartItem item in al)
            {
                Console.WriteLine(item.ItemName + " " + item.Price);
            }

            Console.ReadKey();
        }
        public static void RemoveDuplicatedTokens(ArrayList<ArrayList<QueryToken>> disjuncts)
        {
            IEqualityComparer<string> tokenComparer = new DefaultTokenComparer(DefaultTokenComparer.Options.ConvertUmlauts | DefaultTokenComparer.Options.RemoveDiacritics);

            for (int i = 0; i < disjuncts.Count(); ++i)
            {
                ArrayList<int> tokensToRemove = new ArrayList<int>();
                for (int j = 0; j < disjuncts[i].Count(); ++j)
                {
                    if (!tokensToRemove.Contains(j))
                    {
                        for (int k = j + 1; k < disjuncts[i].Count(); ++k)
                        {
                            if (tokenComparer.Equals(disjuncts[i][j].ToString(), disjuncts[i][k].ToString()))
                                tokensToRemove.Add(k);
                        }
                    }
                }

                tokensToRemove.Sort();
                tokensToRemove.Reverse();

                foreach (var toRemove in tokensToRemove.Distinct()) 
                {
                    disjuncts[i].RemoveAt(toRemove);
                }
            }
        }
		private static IEnumerator Reverse(IEnumerable en)
		{
			var al = new ArrayList();
			foreach (object item in en)
				al.Add(item);
			al.Reverse();
			return al.GetEnumerator();
		}
Example #6
0
        public void initializePlugins()
        {
            if(_initialized)
            {
                InitializationException ex = new InitializationException();
                ex.reason = "plug-ins already initialized";
                throw ex;
            }

            //
            // Invoke initialize() on the plug-ins, in the order they were loaded.
            //
            ArrayList initializedPlugins = new ArrayList();
            try
            {
                foreach(PluginInfo p in _plugins)
                {
                    try
                    {
                        p.plugin.initialize();
                    }
                    catch(PluginInitializationException ex)
                    {
                        throw ex;
                    }
                    catch(System.Exception ex)
                    {
                        PluginInitializationException e = new PluginInitializationException(ex);
                        e.reason = "plugin `" + p.name + "' initialization failed";
                        throw e;
                    }
                    initializedPlugins.Add(p.plugin);
                }
            }
            catch(System.Exception)
            {
                //
                // Destroy the plug-ins that have been successfully initialized, in the
                // reverse order.
                //
                initializedPlugins.Reverse();
                foreach(Plugin p in initializedPlugins)
                {
                    try
                    {
                        p.destroy();
                    }
                    catch(System.Exception)
                    {
                        // Ignore.
                    }
                }
                throw;
            }

            _initialized = true;
        }
Example #7
0
        public static string GetUrl(XmlNode el, string xpath, XmlNamespaceManager nsMgr, Uri documentUri)
        {
            if (el == null)
                return null;
            XmlNode node = nsMgr == null
                ? el.SelectSingleNode(xpath)
                : el.SelectSingleNode(xpath, nsMgr);
            if (node == null)
                return null;
            string rawUrl = node.Value;
            if (rawUrl == null || rawUrl.Length == 0)
                return null;

            // optimize for common case of absolute path
            if (rawUrl.StartsWith("http", StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    return UrlHelper.SafeToAbsoluteUri(new Uri(rawUrl));
                }
                catch { }
            }

            ArrayList ancestors = new ArrayList();

            XmlNode parent = node is XmlAttribute ? ((XmlAttribute)node).OwnerElement : node.ParentNode;
            while (parent != null)
            {
                ancestors.Add(parent);
                parent = parent.ParentNode;
            }

            ancestors.Reverse();

            Uri uri = documentUri;

            foreach (XmlNode anc in ancestors)
            {
                if (anc is XmlElement)
                {
                    XmlElement baseEl = (XmlElement)anc;
                    if (baseEl.HasAttribute("xml:base"))
                    {
                        string thisUri = baseEl.GetAttribute("xml:base");
                        if (uri == null)
                            uri = new Uri(thisUri);
                        else
                            uri = new Uri(uri, thisUri);
                    }
                }
            }

            if (uri == null)
                return UrlHelper.SafeToAbsoluteUri(new Uri(rawUrl));
            else
                return UrlHelper.SafeToAbsoluteUri(new Uri(uri, rawUrl));
        }
Example #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("Basic Array List Testing:");
            ArrayList al = new ArrayList();
            al.Add("Hello");
            al.Add("World");
            al.Add(5);
            al.Add(new FileStream("deleteme", FileMode.Create));

            Console.WriteLine("The array has " + al.Count + " items");

            foreach (object o in al)
            {
                Console.WriteLine(o.ToString());
            }

            Console.WriteLine("\nRemove, Insert and Sort Testing:");
            al = new ArrayList();
            al.Add("Hello");
            al.Add("World");
            al.Add("this");
            al.Add("is");
            al.Add("a");
            al.Add("test");

            Console.WriteLine("\nBefore:");
            foreach (object s in al)
                Console.WriteLine(s.ToString());


            al.Remove("test");
            al.Insert(4, "not");

            al.Sort();

            Console.WriteLine("\nAfter:");
            foreach (object s in al)
                Console.WriteLine(s.ToString());

            al.Sort(new reverseSorter());
            Console.WriteLine("\nReversed:");
            foreach (object s in al)
                Console.WriteLine(s.ToString());

            al.Reverse();
            Console.WriteLine("\nReversed again, different method:");
            foreach (object s in al)
                Console.WriteLine(s.ToString());

            Console.WriteLine("\nBinary Search Example:");
            al = new ArrayList();
            al.AddRange(new string[] { "Hello", "World", "this", "is", "a", "test" });
            foreach (object s in al)
                Console.Write(s + " ");
            Console.WriteLine("\n\"this\" is at index: " + al.BinarySearch("this"));
        }
		public void TestSort()
		{
			ArrayList anArrayList = new ArrayList (){ 1, 2, 3 };	
		
			anArrayList.Sort ();
			Assert.AreEqual (1, anArrayList [0]);

			anArrayList.Reverse ();
			Assert.AreEqual (3, anArrayList [0]);
		}
Example #10
0
	public ArrayList pop_all_since_marker() {
		ArrayList result = new ArrayList();
		object o = pop();
		while (o != this.MARKER) {
			result.Add(o);
			o = pop();
		}
		result.TrimToSize();
		result.Reverse();
		return result;
	}
Example #11
0
 private void LoadNam()
 {
     ArrayList nams = new ArrayList();
     for (int i = 1900; i <= DateTime.Today.Year; ++i)
     {
         nams.Add(i);
     }
     nams.Reverse();
     cbxNam.DataSource = nams;
     cbxNam.SelectedIndex = 0;
 }
        /// <summary>
        /// Processes a list of source items and returns a result.
        /// </summary>
        /// <param name="source">
        /// The source list to process.
        /// </param>
        /// <param name="args">
        /// An optional processor arguments array.
        /// </param>
        /// <returns>
        /// The processing result.
        /// </returns>
        public object Process(ICollection source, object[] args)
        {
            if (source == null || source.Count == 0)
            {
                return source;
            }

            ArrayList list = new ArrayList(source);
            list.Reverse();

            return list;            
        }
Example #13
0
        protected override IList GetChildren(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");

            Stack stack = obj as Stack;
            if (stack == null)
                throw new Exception(string.Format("The type of obj is not {0}", typeof(Stack).FullName));

            ArrayList arrayList = new ArrayList(stack.ToArray());
            arrayList.Reverse();
            return arrayList;
        }
        static void reversearraylist()
        {
            ArrayList list = new ArrayList();
            list.Add ("amardeep");
            list.Add("raja");

            list.Reverse();

            foreach(string s in list) {

                Console.WriteLine("the reversed array is :"  + "  "+ s);
            }
        }
 private void AddWebParts(ArrayList webParts, WebPartZoneBase zone)
 {
     webParts.Reverse();
     foreach (WebPart part in webParts)
     {
         WebPartZoneBase base2 = zone;
         if (!part.AllowZoneChange && (part.Zone != null))
         {
             base2 = part.Zone;
         }
         base.WebPartManager.AddWebPart(part, base2, 0);
     }
 }
Example #16
0
 //////////////////////////////////////////////////////////////////////////////////
 public ArrayList GetAncestors(String id)
 {
     ArrayList ans = new ArrayList();
     while (true)
     {
         Hashtable parentNode = GetParentNode(id);
         if (parentNode == null) break;
         ans.Add(parentNode);
         id = Convert.ToString(parentNode[pidField]);
     }
     ans.Reverse();
     return ans;
 }
Example #17
0
        public UInt32[] ReturnArray()
        {
            UInt32[] uptime_array = { 0, 0, 0, 0, 0 };
            ArrayList uptime_list = new ArrayList(5);
            FileStream fp;
            string line;
            try
            {

                fp = new FileStream("F:/LiveProjects/C#Rookie/Uptime_history.txt", FileMode.Open, FileAccess.Read);
            }
            catch (IOException)
            {
                Console.WriteLine("No history file, returning empty array");
                return uptime_array;
            }

            StreamReader sr = new StreamReader(fp);

            while ((line = sr.ReadLine()) != null)
            {
                uptime_list.Add(line);

            }
            fp.Close();

            uptime_list.Reverse();
            if (uptime_list.Count > 5)
            {
                //we are interested in only the last 5 entries
                for (int z = 0; z < 5; z++)
                {
                    uptime_array[z] = Convert.ToUInt32(uptime_list[z]);
                }
            }

            else if (uptime_list.Count < 5)
            {
                for (int z = 0; z < uptime_list.Count; z++)
                {
                    uptime_array[z] = Convert.ToUInt32(uptime_list[z]);
                }
            }

            for (int z = 0; z < 5; z++)
            {
                Console.WriteLine("reversed contents = " + uptime_array[z]);
            }

            return uptime_array;
        }
Example #18
0
        public static Report CompileFactionLeaderboard()
        {
            Report report = new Report( "Faction Leaderboard", "60%" );

            report.Columns.Add( "28%", "center", "Name" );
            report.Columns.Add( "28%", "center", "Faction" );
            report.Columns.Add( "28%", "center", "Office" );
            report.Columns.Add( "16%", "center", "Kill Points" );

            ArrayList list = new ArrayList();

            List<Faction> factions = Faction.Factions;

            for ( int i = 0; i < factions.Count; ++i )
            {
                Faction faction = factions[i];

                list.AddRange( faction.Members );
            }

            list.Sort();
            list.Reverse();

            for ( int i = 0; i < list.Count && i < 15; ++i )
            {
                PlayerState pl = (PlayerState)list[i];

                string office;

                if ( pl.Faction.Commander == pl.Mobile )
                    office = "Commanding Lord";
                else if ( pl.Finance != null )
                    office = String.Format( "{0} Finance Minister", pl.Finance.Definition.FriendlyName );
                else if ( pl.Sheriff != null )
                    office = String.Format( "{0} Sheriff", pl.Sheriff.Definition.FriendlyName );
                else
                    office = "";

                ReportItem item = new ReportItem();

                item.Values.Add( pl.Mobile.Name );
                item.Values.Add( pl.Faction.Definition.FriendlyName );
                item.Values.Add( office );
                item.Values.Add( pl.KillPoints.ToString(), "N0" );

                report.Items.Add( item );
            }

            return report;
        }
        public void AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode node = e.Node;
            ArrayList list = new ArrayList();
            while (node.Parent != null)
            {
                list.Add(node.Parent.Nodes.IndexOf(node));
                node = node.Parent;
            }
            list.Add(((TreeView) sender).Nodes.IndexOf(node));
            list.Reverse();

            Listener.FireEvent(TesterType, sender, new EventAction("SelectNode", list.ToArray(typeof (object))));
        }
Example #20
0
 private static string makeString(ICollection c)
 {
     StringBuilder sb = new StringBuilder();
     ArrayList list = new ArrayList(c);
     list.Sort();
     list.Reverse();
     for (int i = 0; i < list.Count; i++)
     {
         if (i>0) sb.Append(", ");
         object o = list[i];
         sb.Append(o.ToString());
     }
     return sb.ToString();
 }
        private static ISelection ReverseSelection(ISelection selection)
        {
            ArrayList list = new ArrayList();

            if (selection != null && selection.Items != null)
            {
                foreach (object o in selection.Items)
                    list.Add(o);

                list.Reverse();
            }

            return new Selection(list);
        }
Example #22
0
        // Compare guess and Jumbled Number
        // Returns number of correct digits
        public int CompareGuessandNumJum(JumbledNumber NumJumObj)
        {
            long currGuess,
                currNumJum;

            int numDigits,
                numCorrect = 0,
                gint,
                njint;

            // Get values form NumJum Object
            currGuess = NumJumObj.CurGuess;
            currNumJum = NumJumObj.JNumberValue;
            numDigits = NumJumObj.NumDigits;

            ArrayList guessArray = new ArrayList(),
                numJumArray = new ArrayList();

            // Build array for both the guess and the NumJum for comparison

            for (int i = 0; i < numDigits; i++)
            {
                guessArray.Add((int)(currGuess % 10));
                numJumArray.Add((int)(currNumJum % 10));

                currGuess = (currGuess / 10);
                currNumJum = (currNumJum / 10);
            }

            // Reverse arrays to get in correct order
            guessArray.Reverse();
            numJumArray.Reverse();

            // Use for loops and if statements to compare values

            for (int i = 0; i < numDigits; i++)
            {
                // Use CompareTo method to determine if values are the same
                gint = (int)guessArray[i];
                njint = (int)numJumArray[i];

                if ((gint.CompareTo(njint) == 0))
                {
                    numCorrect++;
                }
            }

            return numCorrect;
        }
Example #23
0
 public static void Check(BPlusTreeLong bpt)
 {
     Console.WriteLine(bpt.ToText());
       bpt.CheckFreeBlock();
       ArrayList allkeys = new ArrayList();
       foreach (DictionaryEntry d in AllInsertHashtable)
       {
     allkeys.Add(d.Key);
       }
       allkeys.Sort();
       allkeys.Reverse();
       foreach (object thing in allkeys)
       {
     string thekey = (string)thing;
     long thevalue = (long)AllInsertHashtable[thing];
     if (thevalue != bpt[thekey])
     {
       throw new ApplicationException("no match on retrieval " + thekey + " --> " + bpt[thekey] + " not " + thevalue);
     }
       }
       allkeys.Reverse();
       string currentkey = bpt.FirstKey();
       foreach (object thing in allkeys)
       {
     string testkey = (string)thing;
     if (currentkey == null)
     {
       throw new ApplicationException("end of keys found when expecting " + testkey);
     }
     if (!testkey.Equals(currentkey))
     {
       throw new ApplicationException("when walking found " + currentkey + " when expecting " + testkey);
     }
     currentkey = bpt.NextKey(testkey);
       }
 }
Example #24
0
 public void GetRecent(string groupId)
 {
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
     CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
     CloudTable table = tableClient.GetTableReference("roomchat");
     table.CreateIfNotExists();
     TableQuery<RoomChatEntity> query = new TableQuery<RoomChatEntity>().Where(TableQuery.GenerateFilterCondition("RoomId", QueryComparisons.Equal, groupId)).Take(20); ;
     ArrayList entities = new ArrayList();
     foreach (RoomChatEntity en in table.ExecuteQuery(query))
     {
         entities.Add(en);
     }
     entities.Reverse();
     Clients.Caller.LoadRecent(groupId, entities);
 }
Example #25
0
        static void Main(string[] args)
        {
            ArrayList shoppingCart = new ArrayList();
            shoppingCart.Add(new ShoppingCartItem("Car", 5000));
            shoppingCart.Add(new ShoppingCartItem("Book", 30));
            shoppingCart.Add(new ShoppingCartItem("Phone", 80));
            shoppingCart.Add(new ShoppingCartItem("Computer", 1000));

            printCart(shoppingCart);

            Console.WriteLine("Sorting...");
            shoppingCart.Sort();
            shoppingCart.Reverse();
            printCart(shoppingCart);
        }
Example #26
0
 //清空游戏元素对应的图片
 public void clearAll()
 {
     ArrayList indexs = new ArrayList();
     foreach(Control item in Controls)
     {
         if (item.GetType().Name.Equals("PictureBox"))
         {
             indexs.Add(Controls.IndexOf(item));
         }
     }
     indexs.Reverse();
     foreach(int index in indexs)
     {
         Controls.RemoveAt(index);
     }
 }
Example #27
0
        internal static void FetchAttendees(User i_LoggedInUser, ListBox i_ListBoxFriendsWithRank)
        {
            List<UserRank<Event>> allUsersWithSharedEvents = CentralSingleton.Instance.AttendeesFromEventListAdapter.UserRankList;
            if (allUsersWithSharedEvents == null)
            {
                allUsersWithSharedEvents = FetchAttendeesFromEvents(i_LoggedInUser);
                CentralSingleton.Instance.AttendeesFromEventListAdapter.UserRankList = allUsersWithSharedEvents;
            }

            ArrayList userRankList = new ArrayList(allUsersWithSharedEvents);
            userRankList.Sort();
            userRankList.Reverse();
            foreach (UserRank<Event> userRank in userRankList)
            {
                i_ListBoxFriendsWithRank.Invoke(new Action(() => i_ListBoxFriendsWithRank.Items.Add(userRank)));
            }
        }
Example #28
0
		string MakeLinkPath(IDirectory directory, HttpRequest request)
		{
			StringBuilder sb = new StringBuilder();
			ArrayList pathList = new ArrayList();

			for(IDirectory dir = directory; dir != null; dir = dir.Parent)
				pathList.Add(dir.Name);

			pathList.RemoveAt(pathList.Count-1);

			pathList.Reverse();

			sb.Append("<a href=\"" + request.Uri.Scheme + "://" + request.Uri.Host);
			if(request.Uri.Port != 80)
				sb.Append(":" + request.Uri.Port);
			sb.Append("/\">");
			sb.Append(request.Uri.Host + "</a>");

			if(pathList.Count > 0)
				sb.Append(" - ");

			StringBuilder reassembledPath = new StringBuilder();

			for(int i = 0; i < pathList.Count; i++)
			{
				string path = pathList[i] as string;

				sb.Append("<a href=\"/");

				reassembledPath.Append(UrlEncoding.Encode(path));
				reassembledPath.Append("/");

				sb.Append(reassembledPath.ToString());

				sb.Append("\">");

				sb.Append(path);

				if(i < pathList.Count-1)
					sb.Append("</a>/");
				else
					sb.Append("</a>");
			}

			return sb.ToString();
		}
Example #29
0
        public static void WriteBoxBorder(HtmlTextWriter writer, string classBorder)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Class, classBorder);
            writer.RenderBeginTag(HtmlTextWriterTag.B);

            ArrayList borders = new ArrayList(_borders);
            if(classBorder.Equals("xbottom"))
                borders.Reverse();

            foreach (string border in borders)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, border);
                writer.RenderBeginTag(HtmlTextWriterTag.B);
                writer.RenderEndTag();
            }

            writer.RenderEndTag();
        }
Example #30
0
        static void Main(string[] args)
        {
            ArrayList myArrayList = new ArrayList();

            myArrayList.Add(10);
            myArrayList.Add(20);
            myArrayList.Add(94);

            //myArrayList.Sort();
            myArrayList.Reverse();

            for (int i = 0; i < myArrayList.Count; i++)
            {
                Console.WriteLine(myArrayList[i]);
            }

            Console.ReadKey();
        }