1/*
2[The "BSD licence"]
3Copyright (c) 2005-2007 Kunle Odutola
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions
8are met:
91. Redistributions of source code MUST RETAIN the above copyright
10   notice, this list of conditions and the following disclaimer.
112. Redistributions in binary form MUST REPRODUCE the above copyright
12   notice, this list of conditions and the following disclaimer in
13   the documentation and/or other materials provided with the
14   distribution.
153. The name of the author may not be used to endorse or promote products
16   derived from this software without specific prior WRITTEN permission.
174. Unless explicitly state otherwise, any contribution intentionally
18   submitted for inclusion in this work to the copyright owner or licensor
19   shall be under the terms and conditions of this license, without any
20   additional terms or conditions.
21
22THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*/
33
34
35namespace Antlr.Runtime.Collections
36{
37	using System;
38	using ArrayList = System.Collections.ArrayList;
39
40	/// <summary>
41	/// Stack abstraction that also supports the IList interface
42	/// </summary>
43	public class StackList : ArrayList
44	{
45		public StackList() : base()
46		{
47		}
48
49		/// <summary>
50		/// Adds an element to the top of the stack list.
51		/// </summary>
52		public void Push(object item)
53		{
54			Add(item);
55		}
56
57		/// <summary>
58		/// Removes the element at the top of the stack list and returns it.
59		/// </summary>
60		/// <returns>The element at the top of the stack.</returns>
61		public object Pop()
62		{
63			object poppedItem = this[this.Count - 1];
64			RemoveAt(this.Count - 1);
65			return poppedItem;
66		}
67
68		/// <summary>
69		/// Removes the element at the top of the stack list without removing it.
70		/// </summary>
71		/// <returns>The element at the top of the stack.</returns>
72		public object Peek()
73		{
74			return this[this.Count - 1];
75		}
76	}
77}