Updated Create Method for Stack + StackNode
This commit is contained in:
parent
ba2f01f836
commit
f263a14170
@ -5,17 +5,17 @@ namespace C_.Datastructures
|
|||||||
internal class Stack<T>
|
internal class Stack<T>
|
||||||
{
|
{
|
||||||
public StackNode<T>? Head { get; set; }
|
public StackNode<T>? Head { get; set; }
|
||||||
private int Count { get; set; }
|
private int Count { get; set; } = 0;
|
||||||
|
|
||||||
public Stack<T> Create(){
|
public Stack<T> Create(){
|
||||||
//Create a new stack without a head
|
//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){
|
public Stack<T> Create(T value){
|
||||||
//Create a new Stack with a head
|
//Create a new Stack with a head
|
||||||
return new Stack<T>{
|
return new Stack<T>{
|
||||||
Head = new StackNode<T>{Value = value, Next = default},
|
Head = StackNode<T>.Create(value, default),
|
||||||
Count = 1
|
Count = 1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user