Code
Hub
Workspaces
Connect
Indexed graphs
Engine
MCP
copy
hub
/
github.com/careercup/ctci
/ shiftStacks
Method
shiftStacks
java/Chapter 3/Question3_5/MyQueue.java:25–31 ·
view source on GitHub ↗
()
Source
from the content-addressed store, hash-verified
23
* do operations on stackOldest.
24
*/
25
private
void
shiftStacks() {
26
if
(stackOldest.isEmpty()) {
27
while
(!stackNewest.isEmpty()) {
28
stackOldest.push(stackNewest.pop());
29
}
30
}
31
}
32
33
public
T peek() {
34
shiftStacks();
Callers
2
peek
Method · 0.95
remove
Method · 0.95
Calls
3
isEmpty
Method · 0.45
push
Method · 0.45
pop
Method · 0.45
Tested by
no test coverage detected