Skip to content

Commit fd3eaaf

Browse files
committed
Update stack.md and queue.md
1 parent 3302354 commit fd3eaaf

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

docs/chapter_stack_and_queue/queue.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,14 @@ comments: true
328328
queSize++;
329329
}
330330
/* 出队 */
331-
int poll() {
331+
void poll() {
332332
int num = peek();
333333
// 删除头结点
334334
ListNode *tmp = front;
335335
front = front->next;
336336
// 释放内存
337337
delete tmp;
338338
queSize--;
339-
return num;
340339
}
341340
/* 访问队首元素 */
342341
int peek() {
@@ -719,11 +718,10 @@ comments: true
719718
rear = (rear + 1) % capacity();
720719
}
721720
/* 出队 */
722-
int poll() {
721+
void poll() {
723722
int num = peek();
724723
// 队头指针向后移动一位,若越过尾部则返回到数组头部
725724
front = (front + 1) % capacity();
726-
return num;
727725
}
728726
/* 访问队首元素 */
729727
int peek() {

docs/chapter_stack_and_queue/stack.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,13 @@ comments: true
313313
stkSize++;
314314
}
315315
/* 出栈 */
316-
int pop() {
316+
void pop() {
317317
int num = top();
318318
ListNode *tmp = stackTop;
319319
stackTop = stackTop->next;
320320
// 释放内存
321321
delete tmp;
322322
stkSize--;
323-
return num;
324323
}
325324
/* 访问栈顶元素 */
326325
int top() {
@@ -657,10 +656,9 @@ comments: true
657656
stack.push_back(num);
658657
}
659658
/* 出栈 */
660-
int pop() {
659+
void pop() {
661660
int oldTop = top();
662661
stack.pop_back();
663-
return oldTop;
664662
}
665663
/* 访问栈顶元素 */
666664
int top() {

0 commit comments

Comments
 (0)