MCPcopy Create free account
hub / github.com/careercup/ctci / push

Method push

java/Chapter 3/Question3_1/Question.java:24–32  ·  view source on GitHub ↗
(int stackNum, int value)

Source from the content-addressed store, hash-verified

22 }
23
24 static void push(int stackNum, int value) throws Exception {
25 /* Check that we have space for the next element */
26 if (stackPointer[stackNum] + 1 >= stackSize) {
27 throw new FullStackException();
28 }
29 /* Increment stack pointer and then update top value*/
30 stackPointer[stackNum]++;
31 buffer[absTopOfStack(stackNum)] = value;
32 }
33
34 static int pop(int stackNum) throws Exception {
35 if (isEmpty(stackNum)) {

Callers 1

mainMethod · 0.95

Calls 1

absTopOfStackMethod · 0.95

Tested by

no test coverage detected