DataStructuresCSharp/C#/Datastructures/Stack.cs

24 lines
588 B
C#
Raw Normal View History

2022-03-26 22:38:49 +00:00
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
};
}
}
}