23 lines
587 B
C#
23 lines
587 B
C#
|
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
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
}
|