예제 #1
0
파일: Stack.cs 프로젝트: kosya/university
 /// <summary>
 /// Method, which returns value of deleted element from the stack
 /// </summary>
 /// <returns>value of the deleted element</returns>
 public int Pop()
 {
     if (!IsEmpty())
     {
         int result = head.Element;
         head = head.Next;
         return result;
     }
     else
     {
         throw new NullReferenceException("No Elements in the stack");
     }
 }
예제 #2
0
파일: Stack.cs 프로젝트: kosya/university
 /// <summary>
 /// Method, which adds a new element in the stack
 /// </summary>
 /// <param name="value">value of the element</param>
 public void Push(int value)
 {
     StackElement tmp = new StackElement(head, value);
     head = tmp;
 }
예제 #3
0
 public StackElement(StackElement next, int value)
 {
     this.Element = value;
     this.Next = next;
 }