From 703826c8a675e4f9915fbfaf15118978c911461c Mon Sep 17 00:00:00 2001 From: Luke Else Date: Thu, 31 Mar 2022 22:05:13 +0100 Subject: [PATCH] Simplified Push Method --- C#/Datastructures/Stack.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/C#/Datastructures/Stack.cs b/C#/Datastructures/Stack.cs index 93f00fb..79859ad 100644 --- a/C#/Datastructures/Stack.cs +++ b/C#/Datastructures/Stack.cs @@ -23,12 +23,7 @@ namespace C_.Datastructures public void Push(T value){ //Add an Item to the top of the stack Count++; - if (Count > 0) - { - Head = StackNode.Create(value, Head); - return; - } - Head = StackNode.Create(value, default); + Head = StackNode.Create(value, Head); return; }