Created Stack class + Creation Methods
This commit is contained in:
parent
6e63055274
commit
8444f0fa0a
24
C#/Datastructures/Stack.cs
Normal file
24
C#/Datastructures/Stack.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using C_.Datastructures.Nodes;
|
||||||
|
|
||||||
|
namespace C_.Datastructures
|
||||||
|
{
|
||||||
|
internal class Stack<T>
|
||||||
|
{
|
||||||
|
|
||||||
|
public StackNode<T>? Head { get; set; }
|
||||||
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
public Stack<T> Create(){
|
||||||
|
//Create a new stack without a head
|
||||||
|
return new Stack<T>{ Head = default, Count = 0};
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stack<T> Create(T value){
|
||||||
|
//Create a new Stack with a head
|
||||||
|
return new Stack<T>{
|
||||||
|
Head = new StackNode<T>{Value = value, Next = default},
|
||||||
|
Count = 1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user