From 8444f0fa0ada06bf2f7ef5dc51723bcf22f03b1b Mon Sep 17 00:00:00 2001 From: Luke Else Date: Sat, 26 Mar 2022 22:38:49 +0000 Subject: [PATCH] Created Stack class + Creation Methods --- C#/Datastructures/Stack.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 C#/Datastructures/Stack.cs diff --git a/C#/Datastructures/Stack.cs b/C#/Datastructures/Stack.cs new file mode 100644 index 0000000..d3841ca --- /dev/null +++ b/C#/Datastructures/Stack.cs @@ -0,0 +1,24 @@ +using C_.Datastructures.Nodes; + +namespace C_.Datastructures +{ + internal class Stack + { + + public StackNode? Head { get; set; } + public int Count { get; set; } + + public Stack Create(){ + //Create a new stack without a head + return new Stack{ Head = default, Count = 0}; + } + + public Stack Create(T value){ + //Create a new Stack with a head + return new Stack{ + Head = new StackNode{Value = value, Next = default}, + Count = 1 + }; + } + } +} \ No newline at end of file