(int stackNum, int value)
| 85 | } |
| 86 | |
| 87 | static void push(int stackNum, int value) throws Exception { |
| 88 | StackData stack = stacks[stackNum]; |
| 89 | /* Check that we have space */ |
| 90 | if (stack.size >= stack.capacity) { |
| 91 | if (numberOfElements() >= total_size) { // Totally full |
| 92 | throw new Exception("Out of space."); |
| 93 | } else { // just need to shift things around |
| 94 | expand(stackNum); |
| 95 | } |
| 96 | } |
| 97 | /* Find the index of the top element in the array + 1, |
| 98 | * and increment the stack pointer */ |
| 99 | stack.size++; |
| 100 | stack.pointer = nextElement(stack.pointer); |
| 101 | buffer[stack.pointer] = value; |
| 102 | } |
| 103 | |
| 104 | static int pop(int stackNum) throws Exception { |
| 105 | StackData stack = stacks[stackNum]; |
no test coverage detected