10 [DebuggerTypeProxy(typeof(System_StackDebugView<>))]
11 [DebuggerDisplay(
"Count = {Count}")]
13 [global::__DynamicallyInvokable]
18 [global::__DynamicallyInvokable]
27 private T currentElement;
32 [global::__DynamicallyInvokable]
35 [global::__DynamicallyInvokable]
46 return currentElement;
53 [global::__DynamicallyInvokable]
56 [global::__DynamicallyInvokable]
67 return currentElement;
74 _version = _stack._version;
76 currentElement =
default(T);
80 [global::__DynamicallyInvokable]
90 [global::__DynamicallyInvokable]
93 if (_version != _stack._version)
100 _index = _stack._size - 1;
101 flag = (_index >= 0);
104 currentElement = _stack._array[_index];
112 flag = (--_index >= 0);
115 currentElement = _stack._array[_index];
119 currentElement =
default(
T);
126 [global::__DynamicallyInvokable]
129 if (_version != _stack._version)
131 System.
ThrowHelper.ThrowInvalidOperationException(
System.ExceptionResource.InvalidOperation_EnumFailedVersion);
134 currentElement =
default(
T);
142 private int _version;
145 private object _syncRoot;
147 private const int _defaultCapacity = 4;
149 private static T[] _emptyArray =
new T[0];
153 [global::__DynamicallyInvokable]
156 [global::__DynamicallyInvokable]
166 [global::__DynamicallyInvokable]
169 [global::__DynamicallyInvokable]
178 [global::__DynamicallyInvokable]
179 object ICollection.SyncRoot
181 [global::__DynamicallyInvokable]
184 if (_syncRoot ==
null)
193 [global::__DynamicallyInvokable]
196 _array = _emptyArray;
205 [global::__DynamicallyInvokable]
210 System.
ThrowHelper.ThrowArgumentOutOfRangeException(
System.ExceptionArgument.capacity,
System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNumRequired);
212 _array =
new T[capacity];
221 [global::__DynamicallyInvokable]
224 if (collection ==
null)
229 if (collection2 !=
null)
231 int count = collection2.
Count;
232 _array =
new T[count];
233 collection2.
CopyTo(_array, 0);
240 foreach (
T item
in collection)
248 [global::__DynamicallyInvokable]
260 [global::__DynamicallyInvokable]
269 if (_array[num] ==
null)
274 else if (_array[num] !=
null && @
default.Equals(_array[num], item))
290 [global::__DynamicallyInvokable]
291 public void CopyTo(T[] array,
int arrayIndex)
297 if (arrayIndex < 0 || arrayIndex > array.Length)
299 System.
ThrowHelper.ThrowArgumentOutOfRangeException(
System.ExceptionArgument.arrayIndex,
System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
301 if (array.Length - arrayIndex < _size)
305 Array.
Copy(_array, 0, array, arrayIndex, _size);
319 [global::__DynamicallyInvokable]
330 if (array.GetLowerBound(0) != 0)
334 if (arrayIndex < 0 || arrayIndex > array.Length)
336 System.
ThrowHelper.ThrowArgumentOutOfRangeException(
System.ExceptionArgument.arrayIndex,
System.ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
338 if (array.Length - arrayIndex < _size)
344 Array.Copy(_array, 0, array, arrayIndex, _size);
345 Array.Reverse(array, arrayIndex, _size);
347 catch (ArrayTypeMismatchException)
355 [global::__DynamicallyInvokable]
358 return new Enumerator(
this);
363 [global::__DynamicallyInvokable]
366 return new Enumerator(
this);
371 [global::__DynamicallyInvokable]
374 return new Enumerator(
this);
378 [global::__DynamicallyInvokable]
381 int num = (int)((
double)_array.Length * 0.9);
384 T[] array =
new T[_size];
394 [global::__DynamicallyInvokable]
401 return _array[_size - 1];
407 [global::__DynamicallyInvokable]
415 T result = _array[--_size];
416 _array[_size] =
default(
T);
422 [global::__DynamicallyInvokable]
425 if (_size == _array.Length)
427 T[] array =
new T[(_array.Length == 0) ? 4 : (2 * _array.Length)];
431 _array[_size++] = item;
437 [global::__DynamicallyInvokable]
440 T[] array =
new T[_size];
441 for (
int i = 0; i < _size; i++)
443 array[i] = _array[_size - i - 1];
int Count
Gets the number of elements contained in the T:System.Collections.Generic.Stack`1.
void CopyTo(T[] array, int arrayIndex)
Copies the T:System.Collections.Generic.Stack`1 to an existing one-dimensional T:System....
Provides a base class for implementations of the T:System.Collections.Generic.IEqualityComparer`1 gen...
T Current
Gets the element at the current position of the enumerator.
void Reset()
Sets the enumerator to its initial position, which is before the first element in the collection.
static void Clear(Array array, int index, int length)
Sets a range of elements in an array to the default value of each element type.
bool Contains(T item)
Determines whether an element is in the T:System.Collections.Generic.Stack`1.
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
static void Reverse(Array array)
Reverses the sequence of the elements in the entire one-dimensional T:System.Array.
new IEnumerator< T > GetEnumerator()
Returns an enumerator that iterates through the collection.
Stack(int capacity)
Initializes a new instance of the T:System.Collections.Generic.Stack`1 class that is empty and has th...
Exposes the enumerator, which supports a simple iteration over a collection of a specified type....
Represents a strongly-typed, read-only collection of elements.
Stack()
Initializes a new instance of the T:System.Collections.Generic.Stack`1 class that is empty and has th...
void CopyTo(T[] array, int arrayIndex)
Copies the elements of the T:System.Collections.Generic.ICollection`1 to an T:System....
static EqualityComparer< T > Default
Returns a default equality comparer for the type specified by the generic argument.
Supports a simple iteration over a generic collection.
Defines methods to manipulate generic collections.
Enumerates the elements of a T:System.Collections.Generic.Stack`1.
void Clear()
Removes all objects from the T:System.Collections.Generic.Stack`1.
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
T Peek()
Returns the object at the top of the T:System.Collections.Generic.Stack`1 without removing it.
T Pop()
Removes and returns the object at the top of the T:System.Collections.Generic.Stack`1.
bool MoveNext()
Advances the enumerator to the next element of the T:System.Collections.Generic.Stack`1.
static int CompareExchange(ref int location1, int value, int comparand)
Compares two 32-bit signed integers for equality and, if they are equal, replaces the first value.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
new T Current
Gets the element in the collection at the current position of the enumerator.
void Push(T item)
Inserts an object at the top of the T:System.Collections.Generic.Stack`1.
T [] ToArray()
Copies the T:System.Collections.Generic.Stack`1 to a new array.
IEnumerator GetEnumerator()
Returns an enumerator that iterates through a collection.
Represents a variable size last-in-first-out (LIFO) collection of instances of the same specified typ...
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
Stack(IEnumerable< T > collection)
Initializes a new instance of the T:System.Collections.Generic.Stack`1 class that contains elements c...
void TrimExcess()
Sets the capacity to the actual number of elements in the T:System.Collections.Generic....
Specifies that the class can be serialized.
int Count
Gets the number of elements contained in the T:System.Collections.ICollection.
void CopyTo(Array array, int index)
Copies the elements of the T:System.Collections.ICollection to an T:System.Array, starting at a parti...
Provides atomic operations for variables that are shared by multiple threads.
void Dispose()
Releases all resources used by the T:System.Collections.Generic.Stack`1.Enumerator.
Supports a simple iteration over a non-generic collection.
Enumerator GetEnumerator()
Returns an enumerator for the T:System.Collections.Generic.Stack`1.