(int stackNum)
| 61 | } |
| 62 | |
| 63 | public static void shift(int stackNum) { |
| 64 | StackData stack = stacks[stackNum]; |
| 65 | if (stack.size >= stack.capacity) { |
| 66 | int nextStack = (stackNum + 1) % number_of_stacks; |
| 67 | shift(nextStack); // make some room |
| 68 | stack.capacity++; |
| 69 | } |
| 70 | for (int i = (stack.start + stack.capacity - 1) % total_size; // end of array |
| 71 | stack.isWithinStack(i, total_size); |
| 72 | i = previousElement(i)) { |
| 73 | buffer[i] = buffer[previousElement(i)]; |
| 74 | } |
| 75 | buffer[stack.start] = 0; |
| 76 | stack.start = nextElement(stack.start); // move start start |
| 77 | stack.pointer = nextElement(stack.pointer); // move stack pointer |
| 78 | stack.capacity--; // return capacity to original |
| 79 | } |
| 80 | |
| 81 | /* Expand stack by shifting over other stacks */ |
| 82 | public static void expand(int stackNum) { |
no test coverage detected