예제 #1
0
 public void push(int stackNr, int value)
 {
     if (stackNr >= 0 && stackNr <= 2 && canAdd())
     {
         {
             StackElement element = new StackElement(last[stackNr], value);
             stack[count]  = element;
             last[stackNr] = count;
             count++;
         }
     }
 }
예제 #2
0
 public StackElement pull(int stackNr)
 {
     if (stackNr >= 0 && stackNr <= 2 && canRemove())
     {
         StackElement elem = stack[last[stackNr]];
         if (elem != null)
         {
             stack[last[stackNr]] = null;
             last[stackNr]        = elem.Previous;
             count--;
             return(elem);
         }
     }
     return(null);
 }