Created Stack class + Creation Methods

This commit is contained in:
Luke Else 2022-03-26 22:38:49 +00:00
parent 6e63055274
commit 8444f0fa0a

View 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
};
}
}
}