Class Stack<T>
A stack implementation.
Inherited Members
Namespace: Advanced.Algorithms.DataStructures.Foundation
Assembly: Advanced.Algorithms.dll
Syntax
public class Stack<T> : IEnumerable<T>, IEnumerable
Type Parameters
Name | Description |
---|---|
T |
Constructors
Stack(StackType)
Declaration
public Stack(StackType type = StackType.Array)
Parameters
Type | Name | Description |
---|---|---|
StackType | type | The stack type to use. |
Properties
Count
The total number of items in this stack.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
GetEnumerator()
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<T> |
Peek()
Peek from stack. Time complexity:O(1).
Declaration
public T Peek()
Returns
Type | Description |
---|---|
T | The item peeked. |
Pop()
Time complexity:O(1).
Declaration
public T Pop()
Returns
Type | Description |
---|---|
T | The item popped. |
Push(T)
Time complexity:O(1).
Declaration
public void Push(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to push. |
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator |