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

Method pop

java/Chapter 3/Question3_1/Question.java:34–42  ·  view source on GitHub ↗
(int stackNum)

Source from the content-addressed store, hash-verified

32 }
33
34 static int pop(int stackNum) throws Exception {
35 if (isEmpty(stackNum)) {
36 throw new EmptyStackException();
37 }
38 int value = buffer[absTopOfStack(stackNum)]; // Get top
39 buffer[absTopOfStack(stackNum)] = 0; // Clear index
40 stackPointer[stackNum]--; // Decrement pointer
41 return value;
42 }
43
44 static int peek(int stackNum) {
45 if (isEmpty(stackNum)) {

Callers 1

mainMethod · 0.95

Calls 2

isEmptyMethod · 0.95
absTopOfStackMethod · 0.95

Tested by

no test coverage detected