Interface IStack<T>
Defines the interface common to all Stack implementations for items of type T
.
Namespace: MoreStructures.Stacks
Assembly: MoreStructures.dll
Syntax
public interface IStack<T>
Type Parameters
Name | Description |
---|---|
T | The type of items, the stack is composed of. |
Remarks
DEFINITION
- A Stack is a data structure storing items of a generic type T
in a LIFO (Last In First
Out) fashion.
- Items are both inserted and extracted at the top (or begin) of the stack.
- Unlike array lists, general random access doesn't come as a easy, performant operation.
- Because data insertion and extraction at a single specific spot is priviledged over any other position in the
data structure, O(1) non amortized cost of insertion and extraction can be provided in some implementations.
- However, arrays and array lists can be used as a backing structure for a stack, and still have O(1) amortized
cost within array boundaries and O(1) amortized cost to remove array boundaries constraints.
- Items are in a total order relationship and duplicates are supported.
Properties
| Improve this Doc View SourceCount
The number of items currently in the stack.
Declaration
int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourcePeek()
Returns the item on top of the stack, without popping it out from the stack.
Declaration
T Peek()
Returns
Type | Description |
---|---|
T | The item of type |
Pop()
Pops the item out from the top of the stack and returns it as a result.
Declaration
T Pop()
Returns
Type | Description |
---|---|
T | The item of type |
Remarks
The item which was on second position at the top of the stack goes on the top after the item on top is popped out.
Push(T)
Push the provided item
onto the top of the stack.
Declaration
void Push(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item of type |
Remarks
The item which was on top of the stack before this push is pushed down onto second position.