Updated Create Method for Stack + StackNode

This commit is contained in:
Luke Else 2022-03-28 22:41:24 +01:00
parent ba2f01f836
commit f263a14170

View File

@ -5,17 +5,17 @@ namespace C_.Datastructures
internal class Stack<T>
{
public StackNode<T>? Head { get; set; }
private int Count { get; set; }
private int Count { get; set; } = 0;
public Stack<T> Create(){
//Create a new stack without a head
return new Stack<T>{ Head = default, Count = 0};
return new Stack<T>();
}
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},
Head = StackNode<T>.Create(value, default),
Count = 1
};
}