mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-02 02:02:57 +08:00
build
This commit is contained in:
@@ -261,7 +261,28 @@ comments: true
|
||||
=== "Dart"
|
||||
|
||||
```dart title="queue.dart"
|
||||
/* 初始化队列 */
|
||||
// 在 Dart 中,队列类 Qeque 是双向队列,也可作为队列使用
|
||||
Queue<int> queue = Queue();
|
||||
|
||||
/* 元素入队 */
|
||||
queue.add(1);
|
||||
queue.add(3);
|
||||
queue.add(2);
|
||||
queue.add(5);
|
||||
queue.add(4);
|
||||
|
||||
/* 访问队首元素 */
|
||||
int peek = queue.first;
|
||||
|
||||
/* 元素出队 */
|
||||
int pop = queue.removeFirst();
|
||||
|
||||
/* 获取队列的长度 */
|
||||
int size = queue.length;
|
||||
|
||||
/* 判断队列是否为空 */
|
||||
bool isEmpty = queue.isEmpty;
|
||||
```
|
||||
|
||||
## 5.2.2. 队列实现
|
||||
|
||||
Reference in New Issue
Block a user