diff --git a/codes/c/chapter_stack_and_queue/array_deque.c b/codes/c/chapter_stack_and_queue/array_deque.c index 704a0a3ef..d0edd519b 100644 --- a/codes/c/chapter_stack_and_queue/array_deque.c +++ b/codes/c/chapter_stack_and_queue/array_deque.c @@ -97,7 +97,7 @@ int peekLast(ArrayDeque *deque) { } /* 队首出队 */ -int pollFirst(ArrayDeque *deque) { +int popFirst(ArrayDeque *deque) { int num = peekFirst(deque); // 队首指针向后移动一位 deque->front = dequeIndex(deque, deque->front + 1); @@ -106,7 +106,7 @@ int pollFirst(ArrayDeque *deque) { } /* 队尾出队 */ -int pollLast(ArrayDeque *deque) { +int popLast(ArrayDeque *deque) { int num = peekLast(deque); deque->queSize--; return num; @@ -149,11 +149,11 @@ int main() { printArrayDeque(deque); /* 元素出队 */ - int pollLastNum = pollLast(deque); - printf("队尾出队元素 = %d,队尾出队后 deque= ", pollLastNum); + int popLastNum = popLast(deque); + printf("队尾出队元素 = %d,队尾出队后 deque= ", popLastNum); printArrayDeque(deque); - int pollFirstNum = pollFirst(deque); - printf("队首出队元素 = %d,队首出队后 deque= ", pollFirstNum); + int popFirstNum = popFirst(deque); + printf("队首出队元素 = %d,队首出队后 deque= ", popFirstNum); printArrayDeque(deque); /* 获取队列的长度 */ diff --git a/codes/c/chapter_stack_and_queue/linkedlist_queue.c b/codes/c/chapter_stack_and_queue/linkedlist_queue.c index cd0da6952..4e66588ee 100644 --- a/codes/c/chapter_stack_and_queue/linkedlist_queue.c +++ b/codes/c/chapter_stack_and_queue/linkedlist_queue.c @@ -68,7 +68,7 @@ int peek(LinkedListQueue *queue) { } /* 出队 */ -void poll(LinkedListQueue *queue) { +void pop(LinkedListQueue *queue) { int num = peek(queue); ListNode *tmp = queue->front; queue->front = queue->front->next; @@ -108,8 +108,8 @@ int main() { printf("队首元素 peek = %d\r\n", peekNum); /* 元素出队 */ - poll(queue); - printf("出队元素 poll = %d,出队后 queue = ", peekNum); + pop(queue); + printf("出队元素 pop = %d,出队后 queue = ", peekNum); printLinkedListQueue(queue); /* 获取队列的长度 */ diff --git a/codes/go/chapter_stack_and_queue/array_deque.go b/codes/go/chapter_stack_and_queue/array_deque.go index 4df7493c9..6481811a6 100644 --- a/codes/go/chapter_stack_and_queue/array_deque.go +++ b/codes/go/chapter_stack_and_queue/array_deque.go @@ -70,7 +70,7 @@ func (q *arrayDeque) pushLast(num int) { } /* 队首出队 */ -func (q *arrayDeque) pollFirst() any { +func (q *arrayDeque) popFirst() any { num := q.peekFirst() // 队首指针向后移动一位 q.front = q.index(q.front + 1) @@ -79,7 +79,7 @@ func (q *arrayDeque) pollFirst() any { } /* 队尾出队 */ -func (q *arrayDeque) pollLast() any { +func (q *arrayDeque) popLast() any { num := q.peekLast() q.queSize-- return num diff --git a/codes/go/chapter_stack_and_queue/deque_test.go b/codes/go/chapter_stack_and_queue/deque_test.go index 8e51901ca..f68a958d0 100644 --- a/codes/go/chapter_stack_and_queue/deque_test.go +++ b/codes/go/chapter_stack_and_queue/deque_test.go @@ -76,11 +76,11 @@ func TestArrayDeque(t *testing.T) { PrintSlice(deque.toSlice()) /* 元素出队 */ - pollFirst := deque.pollFirst() - fmt.Print("队首出队元素 pollFirst = ", pollFirst, ",队首出队后 deque = ") + popFirst := deque.popFirst() + fmt.Print("队首出队元素 popFirst = ", popFirst, ",队首出队后 deque = ") PrintSlice(deque.toSlice()) - pollLast := deque.pollLast() - fmt.Print("队尾出队元素 pollLast = ", pollLast, ",队尾出队后 deque = ") + popLast := deque.popLast() + fmt.Print("队尾出队元素 popLast = ", popLast, ",队尾出队后 deque = ") PrintSlice(deque.toSlice()) /* 获取双向队列的长度 */ diff --git a/codes/rust/chapter_stack_and_queue/linkedlist_deque.rs b/codes/rust/chapter_stack_and_queue/linkedlist_deque.rs index d1f4bec6f..937d1a310 100644 --- a/codes/rust/chapter_stack_and_queue/linkedlist_deque.rs +++ b/codes/rust/chapter_stack_and_queue/linkedlist_deque.rs @@ -99,7 +99,7 @@ impl LinkedListDeque { } /* 出队操作 */ - pub fn poll(&mut self, is_front: bool) -> Option { + pub fn pop(&mut self, is_front: bool) -> Option { if self.is_empty() {return None}; // 队首出队操作 if is_front { @@ -135,13 +135,13 @@ impl LinkedListDeque { } /* 队首出队 */ - pub fn poll_first(&mut self) -> Option { - return self.poll(true); + pub fn pop_first(&mut self) -> Option { + return self.pop(true); } /* 队尾出队 */ - pub fn poll_last(&mut self) -> Option { - return self.poll(false); + pub fn pop_last(&mut self) -> Option { + return self.pop(false); } /* 访问队首元素 */ @@ -190,11 +190,11 @@ fn main() { print_util::print_array(&deque.to_array(deque.peek_first())); /* 元素出队 */ - let poll_last = deque.poll_last().unwrap(); - print!("\n队尾出队元素 = {},队尾出队后 deque = ", poll_last); + let pop_last = deque.pop_last().unwrap(); + print!("\n队尾出队元素 = {},队尾出队后 deque = ", pop_last); print_util::print_array(&deque.to_array(deque.peek_first())); - let poll_first = deque.poll_first().unwrap(); - print!("\n队首出队元素 = {},队首出队后 deque = ", poll_first); + let pop_first = deque.pop_first().unwrap(); + print!("\n队首出队元素 = {},队首出队后 deque = ", pop_first); print_util::print_array(&deque.to_array(deque.peek_first())); /* 获取双向队列的长度 */ diff --git a/codes/rust/chapter_stack_and_queue/linkedlist_queue.rs b/codes/rust/chapter_stack_and_queue/linkedlist_queue.rs index 6eada8379..e0c6dc2ec 100644 --- a/codes/rust/chapter_stack_and_queue/linkedlist_queue.rs +++ b/codes/rust/chapter_stack_and_queue/linkedlist_queue.rs @@ -57,7 +57,7 @@ impl LinkedListQueue { } /* 出队 */ - pub fn poll(&mut self) -> Option { + pub fn pop(&mut self) -> Option { self.front.take().map(|old_front| { match old_front.borrow_mut().next.take() { Some(new_front) => { @@ -107,8 +107,8 @@ fn main() { print!("\n队首元素 peek = {}", peek); /* 元素出队 */ - let poll = queue.poll().unwrap(); - print!("\n出队元素 poll = {},出队后 queue = ", poll); + let pop = queue.pop().unwrap(); + print!("\n出队元素 pop = {},出队后 queue = ", pop); print_util::print_array(&queue.to_array(queue.peek())); /* 获取队列的长度 */