using System; using System.Runtime.InteropServices; namespace System.Collections.Generic { /// Represents a variable size last-in-first-out (LIFO) collection of instances of the same arbitrary type. /// Specifies the type of elements in the stack. /// 1 // Token: 0x02000023 RID: 35 [ComVisible(false)] [Serializable] public class Stack : ICollection, IEnumerable, IEnumerable { /// Initializes a new instance of the class that is empty and has the default initial capacity. // Token: 0x0600015C RID: 348 RVA: 0x000063A0 File Offset: 0x000045A0 public Stack() { } /// Initializes a new instance of the class that is empty and has the specified initial capacity or the default initial capacity, whichever is greater. /// The initial number of elements that the can contain. /// /// is less than zero. // Token: 0x0600015D RID: 349 RVA: 0x000063A8 File Offset: 0x000045A8 public Stack(int count) { if (count < 0) { throw new ArgumentOutOfRangeException("count"); } this._array = new T[count]; } /// Initializes a new instance of the class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied. /// The collection to copy elements from. /// /// is null. // Token: 0x0600015E RID: 350 RVA: 0x000063DC File Offset: 0x000045DC public Stack(IEnumerable collection) { if (collection == null) { throw new ArgumentNullException("collection"); } ICollection collection2 = collection as ICollection; if (collection2 != null) { this._size = collection2.Count; this._array = new T[this._size]; collection2.CopyTo(this._array, 0); } else { foreach (T t in collection) { this.Push(t); } } } /// Gets a value indicating whether access to the is synchronized (thread safe). /// true if access to the is synchronized (thread safe); otherwise, false. In the default implementation of , this property always returns false. // Token: 0x1700005E RID: 94 // (get) Token: 0x0600015F RID: 351 RVA: 0x00006490 File Offset: 0x00004690 bool ICollection.IsSynchronized { get { return false; } } /// Gets an object that can be used to synchronize access to the . /// An object that can be used to synchronize access to the . In the default implementation of , this property always returns the current instance. // Token: 0x1700005F RID: 95 // (get) Token: 0x06000160 RID: 352 RVA: 0x00006494 File Offset: 0x00004694 object ICollection.SyncRoot { get { return this; } } /// Copies the elements of the to an , starting at a particular index. /// The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing. /// The zero-based index in at which copying begins. /// /// is null. /// /// is less than zero. /// /// is multidimensional.-or- does not have zero-based indexing.-or-The number of elements in the source is greater than the available space from to the end of the destination .-or-The type of the source cannot be cast automatically to the type of the destination . // Token: 0x06000161 RID: 353 RVA: 0x00006498 File Offset: 0x00004698 void ICollection.CopyTo(Array dest, int idx) { try { if (this._array != null) { this._array.CopyTo(dest, idx); Array.Reverse(dest, idx, this._size); } } catch (ArrayTypeMismatchException) { throw new ArgumentException(); } } // Token: 0x06000162 RID: 354 RVA: 0x000064F8 File Offset: 0x000046F8 IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } /// Returns an enumerator that iterates through a collection. /// An that can be used to iterate through the collection. // Token: 0x06000163 RID: 355 RVA: 0x00006508 File Offset: 0x00004708 IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } /// Removes all objects from the . /// 1 // Token: 0x06000164 RID: 356 RVA: 0x00006518 File Offset: 0x00004718 public void Clear() { if (this._array != null) { Array.Clear(this._array, 0, this._array.Length); } this._size = 0; this._version++; } /// Determines whether an element is in the . /// true if is found in the ; otherwise, false. /// The object to locate in the . The value can be null for reference types. // Token: 0x06000165 RID: 357 RVA: 0x0000655C File Offset: 0x0000475C public bool Contains(T t) { return this._array != null && Array.IndexOf(this._array, t, 0, this._size) != -1; } /// Copies the to an existing one-dimensional , starting at the specified array index. /// The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing. /// The zero-based index in at which copying begins. /// /// is null. /// /// is less than zero. /// The number of elements in the source is greater than the available space from to the end of the destination . // Token: 0x06000166 RID: 358 RVA: 0x00006588 File Offset: 0x00004788 public void CopyTo(T[] dest, int idx) { if (dest == null) { throw new ArgumentNullException("dest"); } if (idx < 0) { throw new ArgumentOutOfRangeException("idx"); } if (this._array != null) { Array.Copy(this._array, 0, dest, idx, this._size); Array.Reverse(dest, idx, this._size); } } /// Returns the object at the top of the without removing it. /// The object at the top of the . /// The is empty. // Token: 0x06000167 RID: 359 RVA: 0x000065E4 File Offset: 0x000047E4 public T Peek() { if (this._size == 0) { throw new InvalidOperationException(); } return this._array[this._size - 1]; } /// Removes and returns the object at the top of the . /// The object removed from the top of the . /// The is empty. // Token: 0x06000168 RID: 360 RVA: 0x00006618 File Offset: 0x00004818 public T Pop() { if (this._size == 0) { throw new InvalidOperationException(); } this._version++; T t = this._array[--this._size]; this._array[this._size] = default(T); return t; } /// Inserts an object at the top of the . /// The object to push onto the . The value can be null for reference types. // Token: 0x06000169 RID: 361 RVA: 0x0000667C File Offset: 0x0000487C public void Push(T t) { if (this._array == null || this._size == this._array.Length) { Array.Resize(ref this._array, (this._size != 0) ? (2 * this._size) : 16); } this._version++; this._array[this._size++] = t; } /// Copies the to a new array. /// A new array containing copies of the elements of the . // Token: 0x0600016A RID: 362 RVA: 0x000066F8 File Offset: 0x000048F8 public T[] ToArray() { T[] array = new T[this._size]; this.CopyTo(array, 0); return array; } /// Sets the capacity to the actual number of elements in the , if that number is less than 90 percent of current capacity. // Token: 0x0600016B RID: 363 RVA: 0x0000671C File Offset: 0x0000491C public void TrimExcess() { if (this._array != null && (double)this._size < (double)this._array.Length * 0.9) { Array.Resize(ref this._array, this._size); } this._version++; } /// Gets the number of elements contained in the . /// The number of elements contained in the . // Token: 0x17000060 RID: 96 // (get) Token: 0x0600016C RID: 364 RVA: 0x00006774 File Offset: 0x00004974 public int Count { get { return this._size; } } /// Returns an enumerator for the . /// An for the . // Token: 0x0600016D RID: 365 RVA: 0x0000677C File Offset: 0x0000497C public Stack.Enumerator GetEnumerator() { return new Stack.Enumerator(this); } // Token: 0x04000076 RID: 118 private const int INITIAL_SIZE = 16; // Token: 0x04000077 RID: 119 private T[] _array; // Token: 0x04000078 RID: 120 private int _size; // Token: 0x04000079 RID: 121 private int _version; /// Enumerates the elements of a . // Token: 0x02000024 RID: 36 [Serializable] public struct Enumerator : IEnumerator, IDisposable, IEnumerator { // Token: 0x0600016E RID: 366 RVA: 0x00006784 File Offset: 0x00004984 internal Enumerator(Stack t) { this.parent = t; this.idx = -2; this._version = t._version; } /// Sets the enumerator to its initial position, which is before the first element in the collection. This class cannot be inherited. /// The collection was modified after the enumerator was created. // Token: 0x0600016F RID: 367 RVA: 0x000067A4 File Offset: 0x000049A4 void IEnumerator.Reset() { if (this._version != this.parent._version) { throw new InvalidOperationException(); } this.idx = -2; } /// Gets the element at the current position of the enumerator. /// The element in the collection at the current position of the enumerator. /// The enumerator is positioned before the first element of the collection or after the last element. // Token: 0x17000061 RID: 97 // (get) Token: 0x06000170 RID: 368 RVA: 0x000067D8 File Offset: 0x000049D8 object IEnumerator.Current { get { return this.Current; } } /// Releases all resources used by the . // Token: 0x06000171 RID: 369 RVA: 0x000067E8 File Offset: 0x000049E8 public void Dispose() { this.idx = -2; } /// Advances the enumerator to the next element of the . /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. /// The collection was modified after the enumerator was created. // Token: 0x06000172 RID: 370 RVA: 0x000067F4 File Offset: 0x000049F4 public bool MoveNext() { if (this._version != this.parent._version) { throw new InvalidOperationException(); } if (this.idx == -2) { this.idx = this.parent._size; } return this.idx != -1 && --this.idx != -1; } /// Gets the element at the current position of the enumerator. /// The element in the at the current position of the enumerator. /// The enumerator is positioned before the first element of the collection or after the last element. // Token: 0x17000062 RID: 98 // (get) Token: 0x06000173 RID: 371 RVA: 0x00006864 File Offset: 0x00004A64 public T Current { get { if (this.idx < 0) { throw new InvalidOperationException(); } return this.parent._array[this.idx]; } } // Token: 0x0400007A RID: 122 private const int NOT_STARTED = -2; // Token: 0x0400007B RID: 123 private const int FINISHED = -1; // Token: 0x0400007C RID: 124 private Stack parent; // Token: 0x0400007D RID: 125 private int idx; // Token: 0x0400007E RID: 126 private int _version; } } }