MCPcopy Create free account
hub / github.com/Lakhankumawat/LearnCPP / top

Method top

S-Stack/StacksUsingQueue.cpp:102–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100 }
101
102 int top(){
103 if(q1.empty()){
104 cout << "Stack is empty!" << endl;
105 return -1;
106 }
107
108 while(q1.size() != 1){
109 q2.push(q1.front());
110 q1.pop();
111 }
112 int val = q1.front();
113
114 q2.push(q1.front());
115 q1.pop();
116
117 queue<int> temp = q1;
118 q1 = q2;
119 q2 = temp;
120
121 return val;
122 }
123
124 int size(){
125 if(q1.empty()){

Callers

nothing calls this directly

Calls 4

emptyMethod · 0.80
sizeMethod · 0.45
pushMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected