Esempio n. 1
0
 /// <summary>
 /// Get the first element at the top of the stack.
 /// </summary>
 public T Peek()
 {
     if (Top == null)
     {
         return(default(T));
     }
     else
     {
         return(Top.GetData());
     }
 }
Esempio n. 2
0
 public T Peek()
 {
     if (Front == null)
     {
         return(default(T));
     }
     else
     {
         return(Back.GetData());
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Take an element off the top of the Stack.
 /// </summary>
 public T Pop()
 {
     if (Top == null)
     {
         return(default(T));
     }
     else
     {
         SGLNode <T> Temporary = Top;
         Top  = Top.GetNext();
         Size = Size - 1;
         return(Temporary.GetData());
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Used take out the front element of the Queue.
 /// </summary>
 public T Dequeue()
 {
     if (Front == null || Back == null)
     {
         return(default(T));
     }
     else
     {
         SGLNode <T> Temporary = Front;
         Front = Front.GetNext();
         Size  = Size - 1;
         return(Temporary.GetData());
     }
 }