SHARE
TWEET

Untitled

a guest Oct 10th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public interface IStack
  2.     {
  3.         void Push(StackNode node);
  4.         StackNode Pop();
  5.     }
  6.  
  7.     public class Stack : IStack
  8.     {
  9.         private LinkedList<StackNode> _elements;
  10.  
  11.         public Stack()
  12.         {
  13.             _elements = new LinkedList<StackNode>();
  14.         }
  15.  
  16.         public StackNode Pop()
  17.         {
  18.             if (_elements.Count == 0)
  19.             {
  20.                 return null;
  21.             }
  22.             var last = _elements.Last.Value;
  23.             _elements.RemoveLast();
  24.             return last;
  25.         }
  26.  
  27.         public void Push(StackNode node)
  28.         {
  29.             _elements.AddLast(node);
  30.         }
  31.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top