feat: modify some Dart codes and add Dart code blocks to the docs (#543)

This commit is contained in:
liuyuxin
2023-06-02 14:56:29 +08:00
committed by GitHub
parent 53e18bc6d6
commit 281c0c618a
25 changed files with 339 additions and 54 deletions

View File

@@ -255,7 +255,28 @@
=== "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;
```
## 队列实现