public void Push(int num) { StackElement temp = new StackElement(); temp.num = num; temp.next = this.head; this.head = temp; }
/// <summary> /// Push element on stack. /// </summary> /// <param name="value"></param> public void Push(T value) { StackElement <T> temp = new StackElement <T>(); temp.Value = value; temp.Next = this.head; this.head = temp; }
/// <summary> /// Show element on stack and delete it from the stack. /// </summary> /// <returns></returns> public T Pop() { if (head == null) { throw new StackEmptyException(); } T temp = this.head.Value; StackElement <T> pos = this.head; this.head = this.head.Next; return(temp); }
public int Pop() { if (head == null) { Console.WriteLine("Stack is empty!"); return(0); } int temp = this.head.num; StackElement pos = this.head; this.head = this.head.next; return(temp); }
public Stack() { this.head = null; }