Update stack and queue.
This commit is contained in:
@@ -60,6 +60,7 @@ comments: true
|
||||
|
||||
/* 判断队列是否为空 */
|
||||
boolean isEmpty = queue.isEmpty();
|
||||
System.out.println("队列是否为空 = " + isEmpty);
|
||||
```
|
||||
|
||||
=== "C++"
|
||||
@@ -145,10 +146,9 @@ comments: true
|
||||
```java title="array_queue.java"
|
||||
/* 基于环形数组实现的队列 */
|
||||
class ArrayQueue {
|
||||
int[] nums; // 用于存储队列元素的数组
|
||||
int size = 0; // 队列长度(即元素个数)
|
||||
int front = 0; // 头指针,指向队首
|
||||
int rear = 0; // 尾指针,指向队尾 + 1
|
||||
private int[] nums; // 用于存储队列元素的数组
|
||||
private int front = 0; // 头指针,指向队首
|
||||
private int rear = 0; // 尾指针,指向队尾 + 1
|
||||
|
||||
public ArrayQueue(int capacity) {
|
||||
// 初始化数组
|
||||
|
||||
Reference in New Issue
Block a user